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.);
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
  • 4 replies
  • 3546 views
  • 1 like
  • 4 in conversation