Formats and Informats in SAS
Welcome back to Mindful Data Minds! In this session, we’ll explore formats and informats in SAS — two essential tools for representing and interpreting data.
Watch the Full Tutorial
What You Will Learn
- The difference between formats and informats.
- How to apply formats like COMMA, DATE, DDMMYY, DOLLAR, PERCENT, Z.
- How date formats vary by length.
- How informats help SAS read pre-formatted data correctly.
What Are Formats and Informats?
- Format → Controls how data is displayed. It’s about presentation.
- Informat → Controls how data is read into SAS. It’s about input.
In short:
- Format = Output (display)
- Informat = Input (read)
Commonly Used Formats
Let’s look at some of the most common formats applied to numeric variables.
data a;
x=7584;
y=0.75;
run;
1. Comma Format
Adds commas to numbers for readability.
format x comma10.;
Result: 7584 → 7,584
2. Date Format
Converts numeric values (stored as days since 1 Jan 1960) into readable dates.
format x date8.;
Result: 7584 → 06OCT1980
3. DDMMYY Format
Displays dates in day-month-year style.
format x ddmmyy10.;
Result: 7584 → 06-10-1980
4. Dollar Format
Displays numeric values as currency.
format x dollar10.2;
Result: 7584 → $7,584.00
5. Percent Format
Converts fractions into percentages.
format y percent9.2;
Result: 0.75 → 75.00%
6. Z Format
Pads numbers with leading zeros.
format x z8.;
Result: 7584 → 00007584
Variations in Date Formats
SAS date formats range from DATE5. to DATE11.
DATE5.→06OCTDATE7.→06OCT80DATE9.→06OCT1980
Similarly, DDMMYY formats vary by length:
DDMMYY6.→061080DDMMYY8.→06-10-80DDMMYY10.→06-10-1980
Using Informats
When importing pre-formatted data, SAS uses informats to interpret values correctly.
data b;
input x y comma_format date_format DDMMYYD_format DOLLAR_format PERCENT_format z_format;
informat comma_format comma10. date_format date8. DDMMYYD_format DDMMYY10. DOLLAR_format DOLLAR10.2
PERCENT_format PERCENT9.2 z_format z8.;
cards;
7584 0.75 7,584 06OCT80 06-10-1980 $7,584.00 75.00% 00007584
;
run;
Informats ensure SAS reads values like 7584, 0.75, 7,584, 06OCT80, 06-10-1980, $7,584.00, 75.00% or 00007584 correctly and stores them as numeric values internally.
Next Step
Continue learning by exploring the next tutorial in this series. Also subscribe to get notified about new lessons.
Have a Question?
Drop your doubts in the comments below or contact us.
