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

Hi SAS users,

Need help with converting this character date to DATE9 like below.

 

date1 is the input format data is coming in. Date_out should be '01APR2019'd

 

data test;
date1 = '2019-04-01' ;
date2 = dequote(date1);
call symputx("date2" , "'"|| input(put(dequote(date1), yymmdd10.),date9.) ||"'d",'g');
run;

 

%put &date2;

 

Thanks,

Ana

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

please try the below code

 

data test;
date1 = '2019-04-01' ;
call symputx("date2" , cats("'",put(input(date1,yymmdd10.),date9.),"'d"));
run;

 

%put &date2;

 

Thanks,
Jag

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

please try the below code

 

data test;
date1 = '2019-04-01' ;
call symputx("date2" , cats("'",put(input(date1,yymmdd10.),date9.),"'d"));
run;

 

%put &date2;

 

Thanks,
Jag
SASAna
Quartz | Level 8
Thank you. worked very well .
Kurt_Bremser
Super User

Since you need a date literal for use in code, no format us needed:

data test;
date1 = '2019-04-01';
call symputx("date2",input(date1,yymmdd10.),'g');
run;

%put &date2;

See Maxim 28.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 1514 views
  • 0 likes
  • 3 in conversation