BookmarkSubscribeRSS Feed
Newtrix
Calcite | Level 5

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
Calcite | Level 5

Thank you!

Cynthia_sas
SAS Super FREQ
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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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