In this post we will be going through how to get your data into SAS from different data forms or data sources.
We can divide them into following categories
- Entering data directly into SAS data sets – You can feed data directly using DATALINES or CARDS statements. If you are using SAS EG, you can make use of data entry window.
- Creating SAS data sets from raw data files – SAS can read data from different type of raw file. This is the topic of broader discussion, we will be going in details.
- Converting other software’s data files into SAS data sets – We have multiple options for this. We can use PROC import procedure and the import wizard to convert Excel, Dbase, MSAccess file into sas dataset.
- Reading other software’s data files directly – SAS/ACCESS Engine products allows to read the data the data files directly. There are also data engines like SPSS allows to read the data directly.
Reading the data from raw data files
Reading the raw data separated by spaces
Example you have the following data in a raw file
Lucky 2.3 1.9 . 3.0
Spot 4.6 2.5 3.1 .5
Tubs 7.1 . . 3.8
Hop 4.5 3.2 1.9 2.6
Noisy 3.8 1.3 1.8
Winner 5.7 . . .
This data is separated by spaces. In order to read this data, we will write the following program
INPUT Name $ Weight Jump1 Jump2 Jump3;
PROC PRINT DATA = child;
In the above program SAS will recognise the space as it have to read the data into new variable. $ indicates you want to read a character variable. INFILE will try to read the variable until it reaches end of the files.