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

Hi I need to create a dataset with a variable "datetimestamp" from march 2011 to may 2011.

 

So the format I need is...

 

variable name= datetimestamp

timestamp format = 01MAR11:00:00:00 ~ 31MAY11:11:59:59

 

I think this should be pretty simple to do, but I'm stuck.,,,

 

Any help would be greatly appreciated!
Thanks SAS pros in advance!

 

Chloe

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

OK, here goes ...

 

data want;

do datetimestamp = '01MAR2011 00:00:00'dt to '31MAY2011 23:59:59'dt;

   output;

end;

format datetimestamp datetime23.;

run;

 

I'm assuming you want to continue the loop until midnight, not stop at noon.  Thus using 23 as the final hour, not 11.

View solution in original post

5 REPLIES 5
Astounding
PROC Star

SAS date-times represent a single second.  Do you actually want a separate observation for every second between March and May 2011?

imsenny
Calcite | Level 5
Yes...!
imsenny
Calcite | Level 5
I'm trying to analyze some second level data
Astounding
PROC Star

OK, here goes ...

 

data want;

do datetimestamp = '01MAR2011 00:00:00'dt to '31MAY2011 23:59:59'dt;

   output;

end;

format datetimestamp datetime23.;

run;

 

I'm assuming you want to continue the loop until midnight, not stop at noon.  Thus using 23 as the final hour, not 11.

imsenny
Calcite | Level 5

THANK YOU!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1882 views
  • 2 likes
  • 2 in conversation