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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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