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 -
No. Informat tells SAS how to read data. The FORMAT statement tells SAS how to display variable values.
Art, CEO, AnalystFinder.com
Thank you!
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.