home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
e
/
estat21.zip
/
EASIDOC.ZIP
/
ESCHAP07.DOC
< prev
next >
Wrap
Text File
|
1992-06-30
|
21KB
|
661 lines
Chapter 7: FILE MANAGEMENT COMMANDS
7:1. Data
Format: D[ata] [s[ave]] [filename or THIS]
This command reads in data from a file with the name
given, or if the keyword SAVE (which can be shortened
down to S) is used first the data is written to the file.
The data file is simply a text file containing a table of
numerical values arranged in columns beneath one row of
titles which determines the width of each column. The
titles consist of groups of letters or numbers separated
by spaces. There must be no blank rows in the table.
Titles and values must be separated by spaces and not
tabs. If a blank row or one beginning with the word END
is found then that will be taken as the end of the data.
This format should make it possible to transfer data
between EASISTAT files and files used by other software,
including spreadsheets, databases and word processors.
Example data file:
Age Sex GHQ
20 1 12
29 2 13
22 2 14
end
"End" is optional if that is the end of the file or if a
blank line appears instead. The start of each column
position is defined by the left-most letter of each label
(A,S,G). The end of each column is defined by the start
of the next one. The end of the last column is defined by
the end of the title line, so if any data values extended
beyond the end of the first line they would not be read
in correctly (for example if 13 was replaced by 135
above, it would be read in as 13 because the 5 would be
truncated). To prevent this happening extra spaces can be
added to the end of the title line and these spaces would
be included as part of the width of the last title. This
is done automatically by EASISTAT when data files are
saved. Any blank values will be taken as zero.
Examples:
Select command - DATA EXAMPLE.DAT
Reads in data from file EXAMPLE.DAT.
Select command - d s fixed.dat
Saves data in a file called FIXED.DAT. When the data set
has been narrowed down (with the NARROW command) then
only the valid rows will be saved.
Select command - DATA THIS
Using the keyword THIS causes the data to be read from
the current input stream. If you are using EASISTAT from
the keyboard you can type in data as it would appear in a
68
File management commands
file. If it is being run by a command file using the
INPUT command then the data can be included as part of
the input file. It is terminated by a blank line or the
keyword "END". This allows you to keep data in one file
immediately followed by the commands to produce and
derive new columns, and to run the desired statistical
tests on the data.
Example command file to input and modify data:
DATA THIS
age sex beauty
26 1 2
31 2 5
16 2 9.5
end
NEW c4 CODE
DERIVE c4 1*(AGE<20) + 2*((AGE>=20)&(AGE<40)) + 3*(AGE>=40)
DERIVE c4 c4*SEX
If this file is called DATAFILE it is read in with the
INPUT command:
Select command - INPUT DATAFILE
(not DATA DATAFILE, the DATA command occurs within
DATAFILE). Here the DERIVE command is used to combine AGE
and SEX to produce a new variable called CODE.
Output:
Widening data set to include all lines
If a NARROW command had been issued before the data is
read in then it now ceases to apply.
To produce a suitable data file from a word processor
just type out the data in columns as described above,
then save it to disk. If your word processor has an
option to save the text as "ASCII" or "DOS text" or "non-
document" then you must use this option. The EDIT.EXE
program supplied is a simple text editor which can be
used for creating and editing EASISTAT data files. Also,
if you have any problems reading a file with the DATA
command it would be helpful to use EDIT.EXE to study it
to see what might be causing the problem, for example any
special formatting characters that a word processor may
have introduced.
To produce a suitable data file from Lotus 1-2-3:
1. Select "Print", select print to "File".
2. Select the entire range of values as the "Range" to be
printed, with a one line set of titles above if you have
one. There must be a title line above the values in the
data file, so if you do not print one out from 1-2-3 then
you must add one yourself with a word processor
afterwards.
69
File management commands
3. Select "Options".
4. Select margins and set "Left" margin to 0 and "Right"
to 240.
5. Select "Other". Select "Unformatted" output.
6. Go back to print (by selecting "Quit") and select
"Go".
Warning
EASISTAT does not make any automatic backups and does not
warn you if you are going to over-write an existing file.
Saving to the same file as the data was originally in may
be dangerous, since if you have made a mistake then the
original data will be lost. Unless you can be sure always
to specify a new filename with DATA SAVE, it is wise to
make a copy of your data file under another name or onto
another disk. You can do this before entering EASISTAT by
using the DOS command COPY, or while using EASISTAT by
using the SYSTEM COPY command to back up your data, e.g.:
Select command - system copy origdata.dat bkupdata.dat
7:2. Output
Format: O[utput] [filename or close]
The OUTPUT command copies all of the output from EASISTAT
that appears in the top window of the screen to a file or
to the printer. This allows you to save your results and
study them later, and means you can use a word processor
to incorporate them into a document without having to
type them all in again. When you no longer wish to send
output to the file the OUTPUT CLOSE command closes the
file and no further output is copied. OUTPUT writes on to
the end of a file, so if you choose to write to a file
which already exists whatever was previously in that file
will be left as it is and the new results will be tagged
on at the end. If you have a printer hooked up to your
computer you should be able to print out to it directly
by typing OUTPUT PRN.
Examples:
Select command - OUTPUT ANOV0924.OUT
This command copies output into the file ANOV0924.OUT. If
the file does not exist then it will be created. If it
already exists then the new output will be appended to
the old file.
Select command - OUTPUT
Enter name of file to write output to: ANOV0924.OUT
If you do not initially supply a filename, you will be
prompted for one.
70
File management commands
Select command - OUTPUT PRN
From now on all the results will be sent to directly to a
printer if you have one connected. PRN is the special
MSDOS name for the printer. Make sure your printer is
switched on, connected and "on line" before you use this
option. If it does not work it may be because your
printer is not connected to the first parallel port of
your computer. If this is so, instead of PRN try using
LPT2, COM1 or COM2. Consult your DOS manual for details
and see the section on error messages.
Select command - OUTPUT CLOSE
Output will no longer be copied to the file or printer
until another OUTPUT command is given.
Example output:
********************************
* *
* Output from EASISTAT *
* (C) ARC Scientific 1989 *
* *
********************************
This is the first thing OUTPUT will send to the results
file if it is a new file. If the file already exists only
new results will be copied onto the end of it.
Comments
If you use the OUTPUT command to write to a second file
when another one is already being written to then the
first file will be closed and the second file used
instead. You cannot write to two files at once, or to a
printer and a file at the same time.
We recommend that you make extensive use of the ECHO
command to provide titles and comments in your output
file so that when you refer to it later you will be able
to remember what each test was supposed to do. See the
section on the ECHO command.
Using OUTPUT for printing results
Although it is possible to print off results straight
away using PRN as the filename, in general we would
recommend that you should send the results into a file
instead and then use a word processor, the EDIT.EXE
program or the DOS PRINT command (see your DOS manual) to
print off the file when you have finished using EASISTAT.
If you have the results saved in a file on disk then you
have a permanent record which can be printed off as many
times as you like, and in addition you can edit them and
incorporate them directly into a larger document without
onerous retyping.
71
File management commands
7:3. Input
Format: I[input] [filename [param1 param2 ....] or close]
Causes a command file to be read in. Command files
contain commands exactly as they would be typed at the
keyboard.
Examples:
Select command - IN COMM0911.LOG
Select command - i
Enter name of file to read input from (KEY for keyboard):
demo
If you do not initially supply a name for the file then
EASISTAT will ask for it.
Select command - i close
The keyword CLOSE means finish the command file now, as
if the end of the file had been reached.
It is also possible to pass replaceable parameters to a
command file as one can with DOS batch files. These
parameters are typed on the EASISTAT command line after
the file name, and are then substituted wherever %1, %2
... %10 appear in the command file. If you have an input
file called EXAMPLE that contains the following line:
ECHO parm1 %1 parm2 %2 parm3 %3
then entering:
Select command - INPUT EXAMPLE one two testing
will produce the following output:
parm1 one parm2 two parm3 testing
The original purpose of this was to allow you to perform
the same set of tests repeatedly on different columns,
but it is a very flexible feature and can be used in a
variety of other ways as well.
Comments
Command files are a powerful feature of EASISTAT. Long
and complex analyses can be prepared in advance on a word
processor and then can be run automatically without
supervision. As you grow more familiar with EASISTAT you
shold learn to use command files extensively.
The file on your disk called DEMO is a command file.
Please study it to see how it works. Note that you can
also input a command file when you first run EASISTAT by
entering e.g. EASISTAT DEMO. This causes EASISTAT to read
in the command file called DEMO, exactly as if you had
typed INPUT DEMO instead once EASISTAT was running. This
facility means EASISTAT analyses can be run as part of
DOS batch files (in fact the demonstration is usually run
72
File management commands
by a batch file called DEMO.BAT Which contains the line
EASISTAT DEMO).
Normally if EASISTAT finds an error in a command file it
will pause and ask whether to continue or jump to the end
of the file or relinquish control to the keyboard. You
may want to prevent this happening and for EASISTAT to
continue even if it does find errors, perhaps because you
wish to perform some long analyses while the computer is
unattended. To do this use the /I switch in the command
line after the file name:
EASISTAT A-LONG.JOB /I
In this mode EASISTAT will not stop for errors or pauses
in the command file. It may be wise to put a few blank
lines between each command in the command file, so that a
mistake in one does not cause the next to be misread.
Normally when a graphing option is chosen for one of the
EASISTAT commands the graph file will be written to disk
and then EASIGRAF will be run automatically. However
EASIGRAF is not run if a command file is being used,
although the graph file is still written to disk.
Similarly the usual pause does not occur after the
execution of a SYSTEM command.
Command files can be nested up to five deep, that is one
command file can contain an INPUT command to read in
another, and so on. The second will be read through and
when it finishes control is returned to the first file.
It is possible for a command file to transfer control
temporarily to the keyboard as if the keyboard was
another file. To do this the keyword KEY is used:
INPUT KEY
Since the keyboard doesn't end the way a file does, the
only way to get back to the original file is to type:
INPUT CLOSE
Unless the /I switch has been used, every time the
command file comes across the PAUSE command or an error
is found the user is given the option of taking temporary
control at the keyboard by typing K. He or she can later
return to the command file by using the INPUT CLOSE
command. A command file can also be made to pause between
commands by pressing CONTROL-C or CONTROL-BREAK.
Any line in an input file starting with a semi-colon is
ignored. This can be used to put explanatory comments and
reminders into input files.
Here is an example of a fairly complex command file which
takes the names of two columns as parameters and performs
Wilcoxon's signed rank sum test to compare them. If the
file were called WILCSR.INP then one would run it by
entering:
73
File management commands
INPUT WILCSR.INP C14 C15
to compare columns 14 and 15.
ECHO Command file "WILCSR" to perform signed rank sum test
ECHO comparing %1 and %2
LABEL V1 N'
LABEL V2 T1
LABEL V3 T2
LABEL V4 VAR
LABEL V5 MEAN
; use convenient labels to refer to the first four general
; variables
NEW NEXT DIF
DERIVE DIF %1 - %2
; create a new column called DIF, the difference between the
; two columns to be compared
NARROW %1 != %2
; ignore rows in which the values are equal
DERIVE DIF ABS DIF
DERIVE DIF RANK DIF
; alter DIF to contain the ranks of the absolute magnitudes
; of the differences between the columns
BASICS DIF
DERIVE N' XNUMBER
BASICS DIF IF %1>%2
DERIVE T1 XTOTAL
BASICS DIF IF %1<%2
DERIVE T2 XTOTAL
; now N' contains the number of rows used, T1 is the total of
; the ranks of the differences for which the first column is
; larger and T2 of those for which the second is larger
DERIVE VAR N'*(N'+1)*(2*N'+1)/24
DERIVE MEAN 0.25*N'*(N'+1)
ECHO Here are the values for T1, T2 and N':
ARITH T1
ARITH T2
ARITH N'
ECHO Standardised normal deviate (with continuity correction) is:
ARITH (ABS(T1-MEAN)-0.5)/(VAR POW 0.5)
ECHO
ECHO Approximate P value (single-tailed) is:
ARITH 1-PN((ABS(T1-MEAN)-0.5)/(VAR POW 0.5))
; the expected mean and variance are used to calculate the
; standardised normal deviate and therefore significance of the
; result (ties are ignored)
DEL DIF
; finally, the new column created is deleted
The built-in Wilcoxon's signed rank sum test is somewhat
superior to this command file because it takes account of
tied ranks. However this example is designed to
demonstrate the way in which additional statistical tests
not built into EASISTAT can be constructed by hand if
desired.
Another way to use command files might be to set up some
batch files which will run certain simple tests
automatically. For example, the following batch file
called CHISQ.BAT can be run from DOS to perform a two-by-
two chi-squared test:
74
File management commands
rem CHISQ.BAT
if exist chisq.out del chisq.out
echo output chisq.out > chisq.inp
echo chisq n 2 2 >> chisq.inp
echo %1 %2 >> chisq.inp
echo %3 %4 >> chisq.inp
echo quit >> chisq.inp
echo y >> chisq.inp
easistat chisq.inp
type chisq.out
This batch file uses the parameter substitution feature
and ECHO command of DOS (not EASISTAT) to produce a
command file for EASISTAT called CHISQ.INP. If the batch
file were run from DOS as follows:
CHISQ 6 12 34 10
then CHISQ.INP would contain the following lines:
output chisq.out
chisq n 2 2
6 12
34 10
quit
y
When EASISTAT is run the commands in CHISQ.INP are read
in just as if the command INPUT CHISQ.INP had been given
from within EASISTAT. These commands instruct EASISTAT to
send its output to a file called CHISQ.OUT, then to
perform a chi-squared test on a two-by-two table with the
values specified, and then to quit and return to DOS.
Control is thus returned to the batch file which uses the
TYPE command to display CHISQ.OUT on the screen.
7:4. Log
Format: Lo[g] [filename or close]
Produces command files by copying keyboard input to a
file. This log file can then be read in again as a
command file, or it can be edited and elaborated first.
This is a very useful way to get started creating command
files.
All the commands typed in at the keyboard are copied into
the file with the name specified, until the command is
reissued with the filename CLOSE (which cannot be
abbreviated). This provides a very useful record of the
commands typed in during a session. It would then be
possible to repeat exactly the same sequence of commands
on another occasion just by using the INPUT command to
read in the commands from the log file. Alternatively the
file can be adjusted with a text editor such as EDIT.EXE
before being read in again.
75
File management commands
Examples:
Select command - log stat0927.log
Copies all commands into STAT0927.LOG.
Select command - log close
Closes file so that no further commands will be copied.
Like the OUTPUT command, LOG writes onto the end of a
pre-existing file.
7:5. Echo
Format: E[cho] text
Echoes input to output, allowing comments and titles to
appear in output files, or for command files to explain
themselves on screen as they run.
Example:
Select command - e The title of the next test is this
Everything on the line after the echo command is copied
to the output, that is into the top window of the screen
and into an output file if one has been opened. This is
very useful for entering explanatory notes about the
tests one is doing into an output file, because it may be
quite hard when reading them later to work out what is
going on.
See the DEMO file for examples of the use of the ECHO
command (the E at the start of most lines is invoking
ECHO).
7:6. Pause
Format: P[ause]
Produces a pause in a command file.
Example:
Select command - p
Output:
A pause has occurred in the input command file
'E' to end file, 'K' to use keyboard, any other key to continue
The pause allows the user to read what has appeared on
screen. It also gives him or her the chance to abort the
command file, by pressing E, or to take temporary control
of EASISTAT as if the INPUT KEY command had been issued,
by pressing K. In the latter case he or she can return
later to the command file (which remains open) by
entering INPUT CLOSE (to finish keyboard input).
76
File management commands
This command is ignored if EASISTAT has been run with the
/I switch, which causes it to ignore errors and pauses.
77