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

Hi everyone. I am trying my script, to get "datetime" in the format of "201808" into datetime.

 

Here is the code:

  
%let period=201808;
Period=input(catx(':',put(&period, date9.),'00:00:00'), datetime.);

I am expecting to see the result of : 01Aug2018:00:00:00, in datetime format.

 

However, I am only getting the result of 13JUL2512:00:00:00

 

What could be wrong?

 

%let period=201808;

Data want;

Period=.;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data want;
Period=input(catx(':',put(input("&period", yymmn6.),date9.),'00:00:00'), datetime.);
format period datetime20.;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20
data want;
Period=input(catx(':',put(input("&period", yymmn6.),date9.),'00:00:00'), datetime.);
format period datetime20.;
run;
Kurt_Bremser
Super User

&period contains just a number. Interpreting that number as a SAS date value (what you do with

put(&period, date9.)

) renders a date that is 201808 days after 1960-01-01, which gives you that day in 2512.

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