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

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
serrld113
Obsidian | Level 7

This ended up doing exactly what I needed:

 

dob = input(compress(put(year(birthdate),z4.) || put(month(birthdate),z2.) || put(day(birthdate),z2.)),8.);

Untitled.png

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
r_behata
Barite | Level 11
data have;
input dt: anydtdte.;

put dt yymmddn.;
cards;
11/16/1984
03/26/1959
05/02/1967
run;

 

log :

19841116
19590326
19670502
serrld113
Obsidian | Level 7

This ended up doing exactly what I needed:

 

dob = input(compress(put(year(birthdate),z4.) || put(month(birthdate),z2.) || put(day(birthdate),z2.)),8.);

Untitled.png

Tom
Super User Tom
Super User

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.);

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1286 views
  • 2 likes
  • 4 in conversation