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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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