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
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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