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

Dear Experts. 

 

I am facing an issue while converting the below date (given as example) to the date format yymmdd10. 

 

Input Date : Wed Feb 03 00:00:00 CET 2016

 

Output Date: 2016-02-03 (As Expected)

 

I tired to change the input date with ANYDTDTE informat (using the INPUT function as date is coming from macro variable)and then tried to change it to YYMMdd10. format but it did not work out. 

 

Regards,

Gulshan

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello Gulshan,

 

If you only need the date, please try this:

%let d=Wed Feb 03 00:00:00 CET 2016;

data _null_;
d=input(cats(scan("&d",3),scan("&d",2),scan("&d",-1)), date9.);
put d= yymmdd10.;
run;

If you need the full datetime information, I suggest this:

data _null_;
dt=input(cats(scan("&d",3),scan("&d",2),scan("&d",-1)||':'||scan("&d",4)), datetime.);
d=datepart(dt);
put dt= datetime19.;
put d= yymmdd10.;
run;

 

View solution in original post

5 REPLIES 5
Reeza
Super User

What does not work mean?

 

Please post your code and log including any errors you received.

FreelanceReinh
Jade | Level 19

Hello Gulshan,

 

If you only need the date, please try this:

%let d=Wed Feb 03 00:00:00 CET 2016;

data _null_;
d=input(cats(scan("&d",3),scan("&d",2),scan("&d",-1)), date9.);
put d= yymmdd10.;
run;

If you need the full datetime information, I suggest this:

data _null_;
dt=input(cats(scan("&d",3),scan("&d",2),scan("&d",-1)||':'||scan("&d",4)), datetime.);
d=datepart(dt);
put dt= datetime19.;
put d= yymmdd10.;
run;

 

gulshy12
Calcite | Level 5

Hi 

 

 

 

 

data_null__
Jade | Level 19

Perhaps you're not telling the whole story.

34         %put NOTE: &=sysvlong;
NOTE: SYSVLONG=9.04.01M3P062415
35         data _null_;
36            input str $40. @1 date & ANYDTDTE.;
37            format date YYMMdd10. /*worddate.*/;
38            put (_all_)(/=);
39            cards;


str=Wed Feb 03 00:00:00 CET 2016
date=2016-02-03
gulshy12
Calcite | Level 5

Hi Data_null__, 

 

Thanks for the solution. 

 

Regards,

Gulshan

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 1237 views
  • 0 likes
  • 4 in conversation