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
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.
SAS date-times represent a single second. Do you actually want a separate observation for every second between March and May 2011?
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.
THANK YOU!
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.
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.