My Code:
DATA IowaResidents;
INFILE "IowaResidents.csv" DELIMITER = ',' DSD;
INPUT SSN :$11.
Initials :$4.
City :$20.
State :$4.
ZipCd
Sex :$6.
Ethnicity :$12.
Race :$5.
BirthDt :MMDDYY10.;
RUN;
PROC PRINT DATA = IowaResidents;
FORMAT BirthDt ______.;
RUN;
I need BirthDt to display in PROC PRINT as a numeric variable with the first observation being 10622. This example gives me reason to believe that it is a SAS date value. What is the proper informat that I can use in the FORMAT BirthDT ____ that will display the MMDDYY birth date as days since January 1,1960?
You are correct about SAS dates being numeric with 0 being Jan 1 1960. So, the format you need is just a numeric format long enough for the value. 5.0 works in this example.
data have; birthdate = mdy(1,1,1960); put birthdate =; run; proc print data=have; format birthdate 5.0; run;
You are correct about SAS dates being numeric with 0 being Jan 1 1960. So, the format you need is just a numeric format long enough for the value. 5.0 works in this example.
data have; birthdate = mdy(1,1,1960); put birthdate =; run; proc print data=have; format birthdate 5.0; run;
10622 IS most probably the number of days since 1960-01-01 for your birthdate. If you want to display it as a human-readable date, use one of the date formats like the MMDDYY you already mentioned. To simply display the raw number, assign no format at all, and SAS will use the default BEST12. format.
Just what date is 10622 supposed to be?
If that is a SAS date value as implied by your code that would be 01/30/1989 and you would use the format MMDDYY10.
Formats display. Informats read.
If that is not the expected result for 10622 then you need to provide some details, such as what your RAW data from the CSV looks like. Hint: DO NOT open the CSV in a spreadsheet. Open the CSV file with a text editor like Notepad, copy a few lines of the data and then paste the copied lines into a code box opened on the forum with the </> to preserve actual format of your data. The main message windows will reformat text.
Since you have some sensitive data XXXX out the SSN values.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.