SAS TUTORIALS

Best Online SAS Tutorial Tutorials for Beginners

Big Data Analytics

There are three basic options (others do exist) for reading datasets into SAS so you can begin analysis.

1) With an infile statement:

Using an infile statement will bring data in from a different drive (i.e. A, H, C, F) and make them available for the entire SAS session that you run. To do this, the commands could be, for example, if your data were saved on a diskette:

data a1;
infile ‘A:\filename’;
input x1 x2;

You must also name your dataset. You can name it anything you like; here it is named a1. The input statement identifies the variables in your dataset so you can use them for analysis. They can also be named whatever you would like; here they are named x1 and x2.


2) Importing the dataset:

To import the data from another drive, go to File, then import data. In a few seconds, a window will pop up and ask you the format of the file to import.Click on the pull-down menu and select your file type (i.e. Excel, Lotus, text, etc.). Then, click next which will take you to a window that tasks the file’s pathname. Type in the place where your file exists (e.g., H:\StatHW\data). Or, if you are not exactly sure where your file is, click on browse, and this will help you to locate it. Click next again, and then it will ask you to name your data set. This can be anything you would like. Once you name it, you must continue to use this name in your program to reference this particular data set. Click next one more time, and then click on the finish button.

3) Using the cards or datalines statements:

Another option is to put your dataset directly into the program editor. This generally works best when your dataset is fairly small (e.g., for a class assignment). The code for this is:

data a1;
input x1 x2;
cards;
your data here
;
OR
datalines;
your data here
;

It is very important that the last semi-colon go on the next line after all of the data (as shownabove), otherwise your last observation will be deleted!

There was an error in this gadget
Click
For Special
Download