BookmarkSubscribeRSS Feed
Sean_OConnor
Obsidian | Level 7

Hi All,

I have a column with all strings in a date format such as 

 

28/08/1969
19/04/1977
26/07/1956
26/06/1992
11/04/1984

 

data outputdata;
set inputdata ;
newvar = input(dob, mmddyy10.);
format newvar  mmddyy10.;
run;

When I use the following code only some of the strings get converted to an actual SAS date.

 

28/08/1969 .
19/04/1977 .
26/07/1956 .
26/06/1992 .
11/04/1984 11/04/1984

Does anyone know why SAS is converting some of them but not others?

2 REPLIES 2
PaigeMiller
Diamond | Level 26
newvar = input(dob, mmddyy10.);

Look very very carefully. This is not the right informat to use with your data. Can you figure out why? The proper informat is ... well, after you identify why that informat isn't correct to use on your data, I leave that to you to figure out the correct informat as a homework assignment.

--
Paige Miller
Cynthia_sas
Diamond | Level 26
Hi:
Let's take a look at your data -- 28/08/1969 -- there's not a month 28, there could be a day 28. So when you are using the mmddyy10. informat in your INPUT function, you are asking SAS to use 28 as the month. This is just for the first day you show. Looking at the other samples, there's not a month 19 or a month 26 either. @PaigeMiller gave you a hint that you picked the wrong informat. If you experiment with different informats, you should find one that works.
If you look in your SAS log you should have seen a NOTE similar to this:
NOTE: Invalid argument to function INPUT at line ?? column ??

This NOTE means that something was wrong with one of the arguments and since DOB was your character variable, the only other thing that could be wrong was your specification of mmddyy10. as the informat.
Cynthia

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 2 replies
  • 791 views
  • 3 likes
  • 3 in conversation