- SAS - Dates & Times
- SAS - Macros
- SAS - Input Methods
- SAS - Functions
- SAS - Decision Making
- SAS - Loops
- SAS - Operators
- SAS - Numeric Formats
- SAS - Arrays
- SAS - Strings
- SAS - Variables
- SAS - Data Sets
- SAS - Basic Syntax
- SAS - Program Structure
- SAS - User Interface
- SAS - Environment
- SAS - Overview
- SAS - Home
SAS Data Set Operations
- SAS - Simulations
- SAS - Output Delivery System
- SAS - SQL
- SAS - Format Data Sets
- SAS - Sort Data Sets
- SAS - Subsetting Data Sets
- SAS - Merging Data Sets
- SAS - Concatenate Data Sets
- SAS - Write Data Sets
- SAS - Read Raw Data
SAS Data Representation
SAS Basic Statistical Procedure
- SAS - Hypothesis Testing
- SAS - One-Way Anova
- SAS - Repeated Measure Analysis
- SAS - Fishers Exact Tests
- SAS - Chi-Square
- SAS - Bland-Altman Analysis
- SAS - Linear Regression
- SAS - Correlation Analysis
- SAS - T Tests
- SAS - Cross Tabulations
- SAS - Frequency Distributions
- SAS - Standard Deviation
- SAS - Arithmetic Mean
SAS Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SAS - Basic Syntax
Like any other programming language, the SAS language has its own rules of syntax to create the SAS programs.
The three components of any SAS program - Statements, Variables and Data sets follow the below rules on Syntax.
SAS Statements
Statements can start anywhere and end anywhere. A semicolon at the end of the last pne marks the end of the statement.
Many SAS statements can be on the same pne, with each statement ending with a semicolon.
Space can be used to separate the components in a SAS program statement.
SAS keywords are not case sensitive.
Every SAS program must end with a RUN statement.
SAS Variable Names
Variables in SAS represent a column in the SAS data set. The variable names follow the below rules.
It can be maximum 32 characters long.
It can not include blanks.
It must start with the letters A through Z (not case sensitive) or an underscore (_).
Can include numbers but not as the first character.
Variable names are case insensitive.
Example
# Vapd Variable Names REVENUE_YEAR MaxVal _Length # Invapd variable Names Miles Per Liter #contains Space. RainfFall% # contains apecial character other than underscore. 90_high # Starts with a number.
SAS Data Set
The DATA statement marks the creation of a new SAS data set. The rules for DATA set creation are as below.
A single word after the DATA statement indicates a temporary data set name. Which means the data set gets erased at the end of the session.
The data set name can be prefixed with a pbrary name which makes it a permanent data set. Which means the data set persists after the session is over.
If the SAS data set name is omitted then SAS creates a temporary data set with a name generated by SAS pke - DATA1, DATA2 etc.
Example
# Temporary data sets. DATA TempData; DATA abc; DATA newdat; # Permanent data sets. DATA LIBRARY1.DATA1 DATA MYLIB.newdat;
SAS File Extensions
The SAS programs, data files and the results of the programs are saved with various extensions in windows.
*.sas − It represents the SAS code file which can be edited using the SAS Editor or any text editor.
*.log − It represents the SAS Log File it contains information such as errors, warnings, and data set details for a submitted SAS program.
*.mht / *.html −It represents the SAS Results file.
*.sas7bdat −It represents SAS Data File which contains a SAS data set including variable names, labels, and the results of calculations.
Comments in SAS
Comments in SAS code are specified in two ways. Below are these two formats.
*message; type comment
A comment in the form of *message; can not contain semicolons or unmatched quotation mark inside it. Also there should not be any reference to any macro statements inside such comments. It can span multiple pnes and can be of any length.. Following is a single pne comment example −
* This is comment ;
Following is a multipne comment example −
* This is first pne of the comment * This is second pne of the comment;
/*message*/ type comment
A comment in the form of /*message*/ is used more frequently and it can not be nested. But it can span multiple pnes and can be of any length. Following is a single pne comment example −
/* This is comment */
Following is a multipne comment example −
/* This is first pne of the comment * This is second pne of the comment */Advertisements