I am starting from scratch and want to create a dataset that has daily dates (e.g., starting 03/15/2020 through something that would be today's date whenever it is run) for each state (see below for example). I'll then use that as my base to fill in my other conditional variables. How can I do this?
Date State
03/15/2020 AK
03/15/2020 AL
............. ....
03/15/2020 WY
03/16/2020 AK
03/16/2020 AL
and so on through 04/23/2020 (or whatever the current date is for the day it is being run)
Thanks!
data want;
t=today();
do date='15MAR20'd to t by 1;
do state='AL','AK'; /* you type the rest, I'm lazy */
output;
end;
end;
format date yymmdd.;
drop t;
run;
data want;
t=today();
do date='15MAR20'd to t by 1;
do state='AL','AK'; /* you type the rest, I'm lazy */
output;
end;
end;
format date yymmdd.;
drop t;
run;
or if you've already got a table with the states:
proc sql;
create table have_states as
select distinct MapIdName as State
from sashelp.gcstate
where isoalpha3='USA'
;
quit;
data want;
set have_states;
format dt date9.;
do dt='15Mar2020'd to today();
output;
end;
run;
proc print data=want(obs=5);
run;
Do your states have to include the US protectorates like Puerto Rico or Virgin Islands?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: