Informats is used to tell SAS how to read a variable whereas Formats is used to tell SAS how to display or write values of a variable.
Informats is basically used when you read in sample data which is being created using CARDS/DATALINES statement or read or import data from either an external file (Text/Excel/CSV).
Formats can be used in both Data Steps and PROC Steps whereas Informat can be used only in Data Steps.
Example: Read Dates in SAS
- In the example below, we have used INFORMATS ddmmyy8. and ddymmyy10. to read dates in SAS. It creates a dataset called sampledata which is stored in WORK library.
DATA sampledata;INPUT @6 date1 ddmmyy8. @15 date2 ddmmyy10.;CARDS;20-07-19 20-07-2019 ;RUN;chevron_rightfilter_noneThe INFORMATS ddmmyy8. is used to read 20-07-19 date and ddmmyy10. to read 20-07-2019 date. In defined syntax above, 8 and 10 refers to width of the date.
The created dataset looks like below –

It returns 21750 as it is in the SAS date value form. It is not meaningful if you look at the value. You cannot tell which date it is.
- To display the date in usual date format, use FORMAT statement.
DATA sampledata;INPUT @6 date1 ddmmyy8. @15 date2 ddmmyy10.;FORMAT date1 ddmmyy8. date2 ddmmyy10.;CARDS;20-07-19 20-07-2019 ;RUN;chevron_rightfilter_noneOutput:

- How to read DD-MMM-YY format
You can use date11. format for both DD-MMM-YY and DD-MMM-YYYY format.
DATAtemp;INPUT @6 dt date11.;FORMAT dt date11.;CARDS;20-jul-19 ;PROC PRINT noobs;RUN;chevron_rightfilter_noneOutput:

Recommended Posts:
- SAS : How to Display Current Date?
- How to Learn Python in 21 Days?
- Top Programming Languages for Data Science in 2020
- Top 5 Most Loved Programming Languages in 2020
- What happens when we call a Function
- Matrix operations using operator overloading
- How to take input in Octave GNU?
- Switch case statement in Octave GNU
- Comments in Octave GNU
- How to output in Octave GNU
- C Programming For Beginners - A 20 Day Curriculum!
- Python vs Java - Who Will Win the Battle in 2020?
- What is Standard Meta Language (SML)?
- Difference between C and Objective C
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

