DATA Step, Macro, Functions and more

creating date timestamp data set

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

creating date timestamp data set

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


Accepted Solutions
Solution
‎08-10-2016 12:16 PM
Super User
Posts: 5,503

Re: creating date timestamp data set

[ Edited ]

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


All Replies
Super User
Posts: 5,503

Re: creating date timestamp data set

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

Occasional Contributor
Posts: 15

Re: creating date timestamp data set

Yes...!
Occasional Contributor
Posts: 15

Re: creating date timestamp data set

I'm trying to analyze some second level data
Solution
‎08-10-2016 12:16 PM
Super User
Posts: 5,503

Re: creating date timestamp data set

[ Edited ]

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.

Occasional Contributor
Posts: 15

Re: creating date timestamp data set

Posted in reply to Astounding

THANK YOU!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 412 views
  • 2 likes
  • 2 in conversation