Rules for SAS file name and variable name:
- We can give up to 32 characters
- Names start with letters or under score(_)
- We can use letters and numbers
- We can’t use any special characters except under score.
Data set block:
Note: Data set block start with data key board and requires the name of the SAS file.
In file statement:
It is accessing statement, it accept data from internal files or external files.
- If it is a internal data, in file statement followed by cards.
- If it is a external data, in file statement followed by file location.
It is a reading and loading statement in SAS file with variables.
Cards statements (or) data lines:
These 2 statements are used to indicate the internal data.
Data set block closed with ; (or) run statement.
Each and every SAS statement ends with ;
SAS coding can be written in mixed case.
To run the SAS file use F3 (or) F8
100 kumar 34 black
101 kiran 89 white
In raw data, data values are represented by any one special character. This special character is called delimiter.
Default delimiter in SAS is space.
These core tutorials will help you to learn the Rules for SAS file name and variable name.
For an in-depth understanding and practical experience, explore SAS Training Material.
Single level of data set name:
Ex: data demo
If use the single level of data set name, the data set default stores in work library.
Two levels of data set name:
Using 2 levels of data set name, we can store data set in requirwd name.
Data sasuser. demo;
TE: if we write single level of data set name SAS fault convert into 2 levels of data set name.
It is a storage place for SAS files.
SAS file (or) SAS data set:
It stores the data in variables and observation format.
- Each and every column is variable
- Each and every row is observation.
- Each and every data is data value.
Requirements for SAS file:
- Raw data - Numeric
- Name of the SAS file
+And -, decimal (or) E for scientific notation.
Numerals, letters or special characters($ or!) up to 32,767 characters long
Libraries are 3 types
- SAS user
- SAS help
Default destination of SAS file is work library. If we store any data set in work library, it is available at the end of SAS session. Work is temporary storage place for SAS file.
SAS user and SAS help:
Both are the permanent storage place for SAS files, But in SAS user only. user specified files are available , but in SAS help users specified file and system (SAS) specified files are also available.
This concept is used to create a shortcut for external files from outside of SAS environment to SAS environment.
Favorites and folders:
This concept is used to crate a short cut for folders.
It is used to manage a SAS application result. In SAS, output window is managed by a result window.
This is one of the modules in base SAS tool. It is used to create a SAS file(SAS dataset)
SAS file requirements:
- Raw data
- Name of the SAS file
It is 2 types
- Internal data
- External data
If raw data is available in SAS environment (editor window). This raw data is called internal data.
It is available in outside of the SAS environment or external files like txt, excel, oracle….
Using length statement, we can increase the storage for character variable. We can increase the storage capacity up to 256 characters.
SAS system default store upto 12 numbers. Numeric value grater than 12 numbers stores in scientific format. We can convert scientific format into normal format using format statement.
Length name $ 12;
Input pid age name $ race $
123 34 kiran rao Asian 5.6
201 59 pavan kumar Africa 3.4
202 23 lava kumar Asian 4.5
Named input method:
Some times in raw data, data values available with variables names. In this case, we can use named input method.
Data demo 1;
Length name $13;
Input pid = age = name = $;
Pid = 123 age =34 name kiran rao
Pid =201 age=59 name= pavan kumar
Pid =202 age =23 name = lava kumar
Proc print data = demo1;
Column input method:
In raw data, data values are available in specific columns.
Using procedure block, we can analysis and reporting. It starts with PROC keyword and requires procedure options. It is closed with run or quit statement.
Default procedure block generate in output window
Input pid age color $ race $
200 34 white Asian 5.6 78
201 59 black Afirica 3.4 45
202 23 white Asian 4.5 56
Proc print data = sasuser demo;
For indepth knowledge on SAS, click on below
- Normalization in SAS
- SQL Aggregations & DataSet(Row & colummn operations) in SAS
- SQL Statements in SAS
- SAS Interact With Oracle
- SAS Interview Questions & Answers