BookmarkSubscribeRSS Feed
Newtrix
Fluorite | Level 6

Reading a data file into SAS. 1st 2 datalines are as follows:

 

1 New York 07/19/1966 05/10/2015 107 No
2 New Jersey 11/10/1964 . 130 Yes

 

Code I've written:

DATA Homwrk1;
INFILE '/folders/myfolders/hw1_data.txt';
INPUT @1 ID SITE $ 5-14 @20 DOB @35 START @50 GLUCOSE @57 DIABETES $;
INFORMAT DOB START MMDDYY10.;
RUN;

 

Output on date variables is giving me days before/since Jan 1, 1960. Isn't INFORMAT supposed to correct this?

 

Thanks in advance -

4 REPLIES 4
art297
Opal | Level 21

No. Informat tells SAS how to read data. The FORMAT statement tells SAS how to display variable values.

 

Art, CEO, AnalystFinder.com

 

Newtrix
Fluorite | Level 6

Thank you!

Cynthia_sas
Diamond | Level 26
Hi:
INFORMAT tells SAS how to read IN the "raw" data (meaning what pattern or format is the data in when SAS is reading it). The FORMAT tells SAS how to display or show the data on reports. If you want your dates to be displayed in procedure output as readable dates (instead of the number of days since Jan 1, 1960), then you need to also have a FORMAT statement in your code.
Cynthia
Kurt_Bremser
Super User

When posting data, use the window opened with the {i} button. The main posting window compresses whitespace (blanks, tabs), so the data as posted does not match your input statement at all.

Similarly, use the "little running man" for code. This keeps the code "as is" and adds coloring like the Enhanced Editor.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1232 views
  • 1 like
  • 4 in conversation