BookmarkSubscribeRSS Feed
HitmonTran
Pyrite | Level 9

Hi,

I have a date variable (character) and I want to convert it to numeric date value.  however, there are some dates missing day and month.  Is there a format I can easily use along with input function?

 

current in character format:

2009-10-14
2010-12-24
2001-03
2006-06
2012
2002-03-27
2003-02-03
 

 

 


I want  same values but in numeric date:

2009-10-14
2010-12-24
2001-03 
2006-06 
2012 
2002-03-27
2003-02-03

 

 
4 REPLIES 4
PaigeMiller
Diamond | Level 26

The only way I know of that makes sense, is if the day is missing, assign it to 1. If the month is missing, assign it to January. Then all of your records now have a year/month/day, and you can assign a format to them. If necessary, you can also created "flag" variables to indicate if the day was missing or to indicate if the month was missing.

--
Paige Miller
HitmonTran
Pyrite | Level 9
yes, that's how I would normally impute dates but this analysis is not requiring date imputation but I still need a numeric value that is equivalent.
PaigeMiller
Diamond | Level 26

@HitmonTran wrote:
yes, that's how I would normally impute dates but this analysis is not requiring date imputation but I still need a numeric value that is equivalent.

Can you explain further? What are you going to do with this data, where you must work with some calendar information that has no day and some calendar information that has no month?

--
Paige Miller

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 1775 views
  • 3 likes
  • 3 in conversation