Here's a quick way. SAS dates are stored in number of days, so you can use basic arithmetic here.
data frequencydate;
set frequency;
format weekStart date9.;
start_date = '01Nov2018'd;
weekStart = start_date + week*7;
drop start_date;
run;
@Maiio wrote:
Hi,
I'm new to SAS. Can you help me with a more efficient code rather than the one I used below?
Dates for weekstart are increments of 7 days starting 01Nov2018.
Also, I do not want the code to have an end or 'until' date.
data frequencydate;
set frequency;
format weekstart date9.;
if week=0 then weekstart='01Nov2018'd;
else if week= 1 then weekstart='08Nov2018'd;
else if week= 2 then weekstart='15Nov2018'd;
else if week= 3 then weekstart='22Nov2018'd;
else if week= 4 then weekstart='29Nov2018'd;
else if week= 5 then weekstart='06Dec2018'd;
else if week= 6 then weekstart='13Dec2018'd;
else if week= 7 then weekstart='20Dec2018'd;
else if week= 8 then weekstart='27Dec2018'd;
else if week= 9 then weekstart='03Jan2019'd;
else if week= 10 then weekstart='10Jan2019'd;
else if week= 11 then weekstart='17Jan2019'd;
else if week= 12 then weekstart='24Jan2019'd;
else if week= 13 then weekstart='31Jan2019'd;
else if week= 14 then weekstart='07Feb2019'd;
else if week= 15 then weekstart='14Feb2019'd;
else if week= 16 then weekstart='21Feb2019'd;
else if week= 17 then weekstart='28Feb2019'd;
else if week= 18 then weekstart='07Mar2019'd;
else if week= 19 then weekstart='14Mar2019'd;
else if week= 20 then weekstart='21Mar2019'd;
else if week= 21 then weekstart='28Mar2019'd;
run;
Thanks!