SAS for Beginners

Pratibha Singh
5 min readJan 25, 2021

What is SAS?

SAS stands for Statistical Analysis Software/System. It was developed in 1970s at North Carolina State University. It was originally intended for management and analysis of agricultural field experiments. It is now most widely used statistical software. CEO of SAS- Jim Gudnight(Founder of SAS Institute). Products of SAS are SAS/STAT; SAS/GRAPH; SAS/ACCESS.

Getting started with SAS:

When we open the SAS operator we will get the main page as:

Fig.1.1

Here in Fig.1.1 we can see total five windows: Editor window(for editing, modifying, saving, submitting the program), Log Window(for checking errors and warning messages), Output Window(for generating the output of all the programs), Explorer Window(for saving the output as data sets) and Result Window(for displaying all the results from the start of the day to end of the day). [Basic difference between result and output window is that, the former on shows all the output results and the later shows only the result of the current program]

SAS programming starts with a keyword “data” followed by the name we want to save the file with. To terminate the statement we have to use semicolon(;). We will use “input” for adding the columns[Remember to maintain space while writing the column name because one space=one column]. We will be using “datalines” or “cards” for creating rows. We should always add “$” sign for string to be printed, because SAS can read the numerical value but not the character value. Like:

Fig.1.2

Here in Fig.1.2, we can see the use of data, input, datalines and finally run(which can be done by clicking on running boy or F3 or typing “submit” in he space provided on top). To print the code we have to write “proc print”(proc stands for procedure). After this the output window will show the Fig.1.3:

Now to take out the average age group of the people we will use “proc means data=file1” (because we are taking out the mean), and “var age” (because we are using age variable for analysis). The result will be:

Fig.1.4

So in Fig.1.4, N= No. of observation in the data, and we get mean, standard deviation, max value and min value. Now we can also get the chart of this data, by using “gchart” which means graphical chart and specifying the vertical or horizontal even 3D. We can do this by:

And the result will be:

This is possible because we have SAS software in the backend.

Fig.1.7

Fig.1.7, represents the work flow of SAS. Here Raw Data is the data given to be worked on, Data Step(which we create) is from data to Run step, Proc step is from proc to run step, Data set is the result which we get after running the data step. Once it gets generated then it goes for the Proc step i.e., procedure and finally the report.

Saving and accessing the saved file of SAS:

Always remember to save the work done on SAS before closing it down, because a new page gets opened with every new session. To save the work done we need to just go on to File>Save As, or directly from Save icon, on to the computer. To import the earlier data next time with new session follow the step: Put cursor on Editor window>open>select file from saved location on computer>click Open>Save.

SAS uses basic shortcuts to perform the task on codes written like:

ctrl+s>save; ctrl+v>paste; ctrl+X>cut; ctrl+F>find; ctrl+H>replace; ctrl+Z>undo.

Window Descriptions:

Editor Window: We already know all the basic things about editor window like writing program, saving it, running it. Few more things are there like opening book reference to get all he information about the SAS, print, print preview, new(for opening new editor window without closing the earlier one).

Log Window: It is for checking errors and warning massages. Generally four different colored codes are visible here like Blue(notes message-any program run), Black(source-which program is written), Red(errors-no output will be displayed if there is error) and Green(warning-the output will get displayed with warning sign) [Pro-Tip: If you want to become a good programmer, always look into log window after running the program, even when there is no error]. To clear the log put cursor on log window>select New.

Output Window: It gets generated once the procedure is run. It will have default date, time, heading(The SAS System). If we want to remove the title and date just type “title; options nodate;”.

Explorer Window: Here we will find Libraries, shortcuts, favorites and folder and This_PC. Library is the key place where we keep our data. We have only 3 default libraries in SAS: SasUser, SasHelp and Work. SasHelp: where we already have some dataset, which we have not created, and can be used for practice. SasUser: Here whatever we save will be permanent. Work: It is temporary library, as explained earlier. We can also create our own library by- Put cursor on explorer window>new>enter name>browse the location you want to save the file on computer>create.

Result Window: It shows all the result from the starting of the session to the end.

…To Be Continued…

--

--