BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mwhemke
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
CurtisMackWSIPP
Lapis Lazuli | Level 10

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;

View solution in original post

3 REPLIES 3
CurtisMackWSIPP
Lapis Lazuli | Level 10

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;
Kurt_Bremser
Super User

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.

ballardw
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 3 replies
  • 367 views
  • 0 likes
  • 4 in conversation