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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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