Now that we have SAS University Edition installed in our laptops/pcs, lets do a really simple exercise!
As the title of the blog post suggests, the exercise is to create a temporary dataset in SAS. For this we will write a SAS Program.
SAS Program contains of SAS Statements. Each SAS statement has two characteristics:
- Usually begins with a SAS keyword
- Ends with a semi colon(;)
This SAS program contains two steps: i. DATA step ii. PROC step.
- DATA step – basically creates or modifies SAS datasets.
- PROC (or procedure) step – pre-written rules that analyze and process data in a SAS dataset and then produce a report.
Most SAS programs contain either of these two steps or a combination of both these steps.
Program_1 : If we want to construct a dataset that represents only one object, say a machine, we will need only one observation.
data machine; ram = 6; disk = 650; run; proc print data=machine; run;
In the above program :
i. There are six SAS statements.
ii. DATA step – creates a new dataset called machine.
iii. PROC step – prints/displays that dataset in the results/output window.
There is much more to DATA step and PROC step than the function performed in the above program.
Program_2: In statistics, we will mostly deal with datasets that are larger than one observation. Let’s modify the above program to make a larger dataset.
data machine; input ram disk price; cards; 6 650 1000 5 650 950 3 320 500 4 560 890 5 560 910 6 480 860 ; run; proc print data= machine; run;
In the above program:
i. There are seven SAS statements;
ii. This time we used DATA step to modify the machine dataset.
iii. The INPUT statement defines the variables to be read in each line of data.
iv. The CARDS statement indicates to SAS that DATA step statements are completed and the next line contains real data.
v. Notice that the lines of data do not end in a semicolon.
Note : The CARDS statement and DATALINES statement are interchangeable.
Where did SAS store this dataset?
In the explorer tab, click on Libraries > WORK > MACHINE(double click). If the library name is not specified, SAS stores the new datasets in WORK. This is how SAS stored machine dataset: