Type to search

SAS Basics

To Know more about the Different Corporate Training & Consulting Visit our website www.Instrovate.com Or Email : info@instrovate.com or WhatsApp / Call at +91 74289 52788

Data Analytics SAS

SAS Basics


The SAS programs , data files and the results of the programs are saved using various extensions in windows .

The following file extensions are –

*.sas – It represents the SAS code file which can be edited using SAS editor or text editor.

*.log – It represents the SAS Log file . It contains information such as errors, warnings etc.

*.sas7bdat – it represents SAS data file which contains a SAS data set including variable names , labels and observation.

Important SAS Keyboard Shortcuts

Description                                                                                Shortcut key

Run or submit a program                                F3 or F8

Comment the selected code                                Ctrl + /

Stop Processing or cancel submitted program                Ctrl+ Break

Convert selected text to upper case                        Ctrl + Shift + U

Find text                                                Ctrl + F

Find and replace text                                        Ctrl + H

Copy selection                                                Ctrl + C

Paste                                                        Ctrl + V

Cut selection                                                Ctrl + X

Go to a particular line                                        Ctrl + G

Move to beginning of line                                Home

Move to top                                                Ctrl + Home

Move to end                                                Ctrl + End

To close the active window                                Ctrl + F4

To exit the SAS System                                        Alt + F4

Open a new program window                                F4


Permanent library

We can create permanent library by following steps –

First click on leftmost button under Libraries .

SAS Basics 29

It will open following window of New Library –

SAS Basics 30

We give name satya to new library . We click on checkbox to re-create library every time when we open SAS Studio.  

SAS Basics 31

We click on Browse  , then it will open this window –

SAS Basics 32

Then , click on OK button to create library .

We can see SATYA library under My Libraries tab  as –

SAS Basics 33

We can also create permanent library by using libname statement in SAS 9.2 window version.

libname satya “C:\Users\dell\Desktop”;

We create a new dataset apple and store in satya library.

Data satya.apple;

SAS Basics 34

You can see library SATYA store APPLE dataset .

SAS Basics 35

We do not store anything in our dataset . So , it shows this window –

SAS Basics 36

Temporary library

We create a dataset to store it temporarily as –

Data abc;


Data work.abc;

SAS Basics 37

The dataset stores in Work library . As you can see ABC dataset under Work library in below window –

SAS Basics 38

Data step

The structure of Data step  is as-

Data dataset_name;

Input variable_names;


Data             <-    We enter data to store in dataset

;               <-     It shows end of data


Data  – It is used to create a dataset with dataset_name as name of the dataset .

Input – It shows the list of variable names.

Datalines/Cards – It is used to read data internally. We used Cards in previous version of SAS.

Data – it shows the data to store in the dataset.

Run  – To execute the program .

SAS variable types

It has two types –

Numeric variable

This is the default variable type . It store only digits from 0 to 9 .

Syntax –


We create three variables VAR1 , VAR2 , VAR3 .

We can create id ,salary  and age variables as –

Input id salary age ;

Character Variable

It store data which includes string, digits and special symbols like marine , abc12 , #dfg89 etc.

Syntax –


We create two character variables VAR1 , VAR2.

We create character variables name , gender as –

Input name $ gender $;

We create a new dataset “new” . It stores name and marks of students .SAS reads line-by-line to store data in dataset .It reads data column-wise separated by space.  

Data new;

input name$ marks;


Satya 45

Ram 78



We can execute our SAS code by using F3 function key .

It shows output of program in OUTPUT DATA window –

SAS Basics 39

We create a dataset “abc” . It includes id , name and salary .

data abc;

input id name$ salary ;


101 Dan 45000

102 Derry 8564

103 Henry 87562



We can execute our SAS code by using F3 function key .

The output of SAS code can be seen in OUTPUT DATA window –

SAS Basics 40

The dataset ABC store in WORK library .

SAS Basics 41

Previous Article