How to Write a Simple SAS Program
SAS (Statistical Analysis System) is the simplest programming language that you may ever find. SAS makes programming easy, since it is done in steps that are simple to understand. Writing a SAS program can be simple if you understand what is required. Following the steps below can simplify the task for you.
Instructions
-
-
1
Understand what you need to accomplish from the assignment. Confer with your client or your supervisor to make sure that you know exactly what is needed.
-
2
Get a copy of the layout of the data file you will need to access so you know where the variables you need are located.
-
-
3
Start the program with telling it where the data is located. This is called an infile. You must let SAS know where the data is stored so it can access it. Use the samples in the resource section as models to work from.
-
4
Input the data into the program. You must define the variables in this data step. It is necessary to use the layout of the data file so you are sure to get the right variable. If a variable is located at position 50 in the file and you access it at 51, you will have the wrong information. Also, if you tell SAS the field is four characters in length and its five you will get the wrong data.
-
5
Perform the necessary steps to complete your assignment. This may include adding new variables, sorting your data, setting up frequencies and making new formats for your variables. No matter what your client has asked for you can accomplish it in a SAS program.
-
6
Run the program. If there are any errors, SAS will tell you where they are and what the problem is. You can understand it without much trouble, unlike other programming languages. Fix any problems, and run the program again.
-
7
Complete the project and give the information to your client or supervisor. You have now successfully written a SAS program!
-
1
Tips & Warnings
Remember programming is like writing directions. You must be very precise.
You can call your variable any name you choose but they can't be longer than eight letters, numbers or characters.
Be very careful that you have the correct information for each variable.