BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vraj1
Quartz | Level 8

I have a char date which is something like "17 Nov 2016" and i want to make it as "2016-11-17".

 

Tried  A=INPUT(E,is8601da.); 

 

But it didnt work as the input is char variable.

 

Any help?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Convert it to an actual date and then convert it back into a character string.

A=put(input(E,date11.),yymmdd10.);

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

Try next code:

sas_date = cats('"', input(compress(date_in), 'D"',date9.);

format sas_date yymmdd10.;

vraj1
Quartz | Level 8

I get error while using

data ec;
6528
6529 dat="17 Nov 2016";
6530 sas_date = cats('"', input(compress(dat), 'D"',date9.);
----
85
76
ERROR 85-322: Expecting a format name.

ERROR 76-322: Syntax error, statement will be ignored.

Tom
Super User Tom
Super User

Convert it to an actual date and then convert it back into a character string.

A=put(input(E,date11.),yymmdd10.);

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
  • 2706 views
  • 1 like
  • 4 in conversation