BookmarkSubscribeRSS Feed
Aayushi_17
Quartz | Level 8

Hi all

here am writing d code to check missing day month year from the input below  & display the correct format according to the given values below. my input dates are 

YYYY-MM-
YYYY

YYYY- - DD
MM-DD

the values to display according to the corresponding input value in the output should be in sas numeric date format since these dates  values are missing  how to display them as output ?

thanks in advance

4 REPLIES 4
PaigeMiller
Diamond | Level 26

There's no such thing as a SAS numeric date format that will handle all of the possible combinations of missing you show.

 

You probably ought to read in these dates with missing fields as text, and then display them as text.

--
Paige Miller
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

dirty data in equals results that are unreliable.  Send the data back to the compiler or the person who supplied the data and make them correct the issue.  Or get with the DB Admin and make that date field mandatory valid date required.

 

It's all fun and games until someone losses an eye.

 

Kurt_Bremser
Super User

You need to first state rules how those missing month and day values need to be replaced (eg should a missing month be set to January, or June, or December?).

Once these rules are known, they can be put into code.

SuryaKiran
Meteorite | Level 14

Hi,

 

SAS stores date values as numeric values, i.e. number of days from 1st Jan 1960 (this is not a format, just numeric values and needs format to be given to represent as dates that we can understand).

 

YYYY-MM-   Here missing day values, so it can be any value between 0-31  (31 dates possibility)
YYYY           Here missing month and date (365 dates possible)

YYYY- - DD Here missing month (12 dates possible)
MM-DD      Here missing year (infinite dates possible) 

 

Set rules to consider one value out of all the possible values. 

 

Thanks,
Suryakiran

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
  • 1767 views
  • 0 likes
  • 5 in conversation