Learn Basic SAS Programming for beginners part I


This post will help you to learn basic SAS programming skills and You'll learn how SAS data sets are stored temporarily or permanently in SAS libraries. You'll also learn details about SAS data sets, which are files that contain data that is logically arranged in a form that SAS can understand. SAS programs used to access, manage, analyze, or present data. Let's begin by looking at a simple SAS program.

data clinic.admit2;
set clinic.admit;
run;
proc print data=clinic.admit2;
run;

This program creates a new SAS data set from an existing SAS data set and then prints a listing
of the new data set. A SAS data set is a data file that is formatted in a way that SAS can
understand.

Syntax rules:
  • It usually begins with a SAS keyword.
  • All commands end in a semi-colon
  • SAS statements are not case sensitive. You may use upper or lower case.
  • Variables names can be upper or lower case.
  • When you refer to "external" file name, it is case-sensitive (interaction with UNIX operating system).
  • Commands can extend over several lines as long as words are not split.
  • You may have more than one command per line.
  • SAS name rules (for datasets and variables): up to 32 characters long; must start with a letter or an underscore (“_”). Avoid special characters.

Blocks/Components of a SAS program:

There are two main parts in a SAS program,
1. Data step
2. PROC (procedure) step

A SAS program can consist of a DATA step or a PROC step or any combination of DATA and PROC steps.

DATA steps typically create or modify SAS data sets. They can also be used to produce customdesigned
reports. For example, you can use DATA steps to
  • put your data into a SAS data set
  • compute values
  • check for and correct errors in your data
  • produce new SAS data sets by subsetting, merging, and updating existing data sets.


PROC (procedure) steps are pre-written routines that enable you to analyze and process the
data in a SAS data set and to present the data in the form of a report. PROC steps sometimes
create new SAS data sets that contain the results of the procedure. PROC steps can list, sort,
and summarize data. For example, you can use PROC steps to
  • create a report that lists the data
  • produce descriptive statistics
  • create a summary report
  • produce plots and charts.

Statements in a SAS program:

  1. a DATA statement, ex: data clinic.admit2;
  2. a SET statement, ex: set clinic.admit;
  3. a RUN statement, ex: run;
  4. a PROC PRINT statement, proc print data=clinic.admit2;
  5. another RUN statement, run;

Format of SAS programs:

SAS statements are in free format. This means that
  • they can begin and end anywhere on a line.
  • one statement can continue over several lines.
  • several statements can be on a line.


Share/Bookmark

0 comments:

Post a Comment

Your suggestions are welcome:

Followers

Networked Followers

TopOfBlogs

  © Copyright Techwebbee by Techwebbee 2010

Back to TOP