BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

In my data, the date variable has values 16/Oct/2015 and un/Jan/2016.

 

I am using the code to convert to IS8601 dates.

code:

date1=input(date,date11.);
isdate=put(date1,is8601da.);

 

This code is not converting the "un/Jan/2016". What should I include in my code. I need value '2016-01' for '"un/Jan/2016".'  Please help. Thanks.

1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
What is the 'un'? Is it a code that stands for "unknown" or is it the word for a number un=uno?

In either case, assuming that date is a character variable and that you need to substitute a day value for the 'un' for the INPUT to work correctly, you have to pick a day value to substitute for the 'un' - I generally choose 01, but you could choose 15 or 30 or any other number.

I would suggest a simple IF statement (not tested):
if index(date,'un') > 0 then do;
date1 = input(catt('01'||substr(date,3)),date11.);
end;
else date1=input(date,date11.);

cynthia
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
  • 1 reply
  • 1006 views
  • 1 like
  • 2 in conversation