Contents Up << >>

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:

Enter command -  DATA example.dat
Reads in data from file called example.dat. Note that the filenames on some operating systems are case sensitive.

Enter command -  d s fixed.dat
Saves data in a file called fixed.dat.

NB When the data set has been narrowed down (with the NARROW command) then only the valid rows will be saved. Values will be saved in text format using the precision to which they are displayed using the FORMAT command. This can be viewed using the LIST command. By default, columns are formatted to be displayed with zero decimal places, so unless this is changed no fractional part of any value will be saved. To save to a higher precision, columns must be reformatted before the file is saved. Normally one would have an input file which would reformat each column as required.

Enter command -  d s fixed.dat

Enter 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 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
fo beauty 6 1
NEW c4 CODE 4 0
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:

Enter 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. Alternatively, use an editor designed for dealing with plain text files.

To produce a suitable file from Excel, choose the option to Save As Formatted Text (Space delimited) (*.prn). Other file types have the columns separated by tabs, not spaces, and so will not be read correctly by EASISTAT.

In general, if you have any trouble reading a data file you should check that there are spaces between the columns and not tabs. The columns may look appropriately aligned in a text editor but will not be read correctly by EASISTAT unless they are separated by the correct number of spaces.

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 MS-DOS command COPY, or while using EASISTAT by using the SYSTEM COPY command to back up your data, e.g.:

Enter command -  system copy origdata.dat bkupdata.dat