SAS | Date Formats and Informats
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?
- 12 Reasons Why You Should Learn Python in 2019
- 5 Most Difficult Programming Languages of the World
- Object Oriented Programming in Ruby | Set-2
- Difference Between Programming, Scripting, and Markup Languages
- Walrus Operator in Python 3.8
- 7 Tips and Tricks to Learn Programming Faster
- Object-Oriented Programming in Ruby | Set 1
- SAS | Delete Empty Rows
- SAS | COALESCE Function with Examples
- Where Statement in SAS Programming
- How to import data into SAS?
- If-Then-Else statement in SAS Programming
- How to drop variables from a dataset in SAS Programming?
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.



