SAS TUTORIALS

Best Online SAS Tutorial Tutorials for Beginners

Big Data Analytics

5:42 AM

Basic Syntax

Important basic syntax to know:

In order to successfully run any program, you need the following basic elements:

1) a semi-colon at the end of every line
2) a data statement that names your data set (unless you import the data set)
3) input statement (unless you import the data set)
4) at least one space between each word or statement
5) a run statement

A semi-colon is the way to tell SAS that a particular operation, procedure, or statement is finished, and tells SAS to look for the next one. The data statement names your data set so you can reference it later in your program. The input statement tells SAS the names of the variables in your data set so that they can also be referenced later. Only one space is required to tell SAS that things are separate. If you have more than one space, that is fine too. A run statement tells SAS to process the previous bit of code that you wrote. If there is no run statement, SAS will not process anything. (Lack of semi-colons and run statements are two most common mistakes in a program.

An example of this follows:

data yourdatasetname;
infile ‘H:\StatHW\yourfilename.dat’;
input variable1 variable2 (up to however many variables that
you have);

If you use the cards or datalines statements instead, they must both be preceded by the input statement.
An example of using the cards statement to read in data is on the following page.

There was an error in this gadget
Click
For Special
Download