Help turning mmddyy10. to numeric format.
My dates look life this:
11/16/1984
03/26/1959
05/02/1967
I want them to look like this:
19841116
19590326
19670502
Thank you
This ended up doing exactly what I needed:
dob = input(compress(put(year(birthdate),z4.) || put(month(birthdate),z2.) || put(day(birthdate),z2.)),8.);
@serrld113 wrote:
Help turning mmddyy10. to numeric format.
My dates look life this:
11/16/1984
03/26/1959
05/02/1967
I want them to look like this:
19841116
19590326
19670502
Thank you
mmddyy10 are numeric, mmddyy10 is a format
All you have to do is assign a different format to this variable, whatever format you would like, such as YYMMDDN8.
data have;
input dt: anydtdte.;
put dt yymmddn.;
cards;
11/16/1984
03/26/1959
05/02/1967
run;
log :
19841116 19590326 19670502
This ended up doing exactly what I needed:
dob = input(compress(put(year(birthdate),z4.) || put(month(birthdate),z2.) || put(day(birthdate),z2.)),8.);
Why do you want to store a date in such a confusing way? How will you be able to use it in the form? How is it useful to have the 16th of November 1984 stored as the number 19,841,116?
Note you could just use the YYMMDDN format with the PUT() function to generate the string you need for your INPUT() function.
dob = input(put(birthdate,yymmddn8.),8.);
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.