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.);
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: