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
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;
What does not work mean?
Please post your code and log including any errors you received.
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;
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
Hi Data_null__,
Thanks for the solution.
Regards,
Gulshan
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.