1. SAS USER DEFINED FORMAT
School of Data Science
www.handsonsystem.com
2. SAS Format
SAS Defined Format
• These formats are present in SAS, user
can use this directly.
User Defined Format
• Users are able to create the format as
required and then those can be used in
“Proc” & “Data” step.
SAS Format
www.handsonsystem.com
3. SAS User Defined Format
Syntax :
PROC FORMAT;
VALUE format-name range 1= ‘ label’
range 2= ‘ label’
…..;
RUN;
www.handsonsystem.com
4. SAS User Defined Format
Example :
PROC FORMAT;
VALUE $grade AA = ‘ Very Good’
A+= ‘Good’
B = ‘ Fair’
C = ‘Bad’ ;
RUN;
PROC FORMAT;
VALUE race 1= ‘ Asian’
2= ‘American’
3= ‘African’
4=‘Unknown’;
RUN;
Numeric
Character
www.handsonsystem.com
5. Format Name:
<$> format<w>.<d>
Indicates a
character
format
Format Name
Total width (including decimal
places and special characters)
Required
delimiter
Number of
decimal
places
www.handsonsystem.com
6. Proc print data=input_dataset;
Format variable_name $grade.;
Additional SAS statements;
Run;
Data output_dataset;
Set input_dataset;
Format variable_name race.;
Additional SAS statements;
Run;
SAS User Defined Format Example:
C
H
A
R
A
C
T
E
R
N
U
M
A
R
I
C
www.handsonsystem.com