data wwk;
do weekday ='01-Jan-2019'd to'31-Dec-2019'd ;
if weekday =1 then output ;
end;
format weekday date9.;
run;
i want output like
DATE | Weekday |
05-01-2019 | Saturday |
05-02-2019 | Tuesday |
05-03-2019 | Tuesday |
05-04-2019 | Friday |
05-05-2019 | Sunday |
05-06-2019 | Wednesday |
05-07-2019 | Friday |
05-08-2019 | Monday |
05-09-2019 | Thursday |
05-10-2019 | Saturday |
05-11-2019 | Tuesday |
05-12-2019 | Thursday |
Try this. It is a bit more effecient, as it loops over months and not over days (12 vs. 365).
data wrk (drop=start end i);
format date ddmmyyd10.;
start = '01-Jan-2019'd;
end = '31-Dec-2019'd ;
do i = 0 to intck('month',start,end);
Date = intnx('month',start,i)+4;
Weekday = left(put(date,downame.));
output;
end;
run;
Try this. It is a bit more effecient, as it loops over months and not over days (12 vs. 365).
data wrk (drop=start end i);
format date ddmmyyd10.;
start = '01-Jan-2019'd;
end = '31-Dec-2019'd ;
do i = 0 to intck('month',start,end);
Date = intnx('month',start,i)+4;
Weekday = left(put(date,downame.));
output;
end;
run;
data wwk;
do date ='01Jan2019'd to'31Dec2019'd ;
if day(date) =5 then output ;
weekday=weekday(date);
end;
format date date9. weekday DOWNAME9.;
run;
Hi
Jagadish not getting desired output as per 2019 year
Make it simpler using MDY function and a do loop.
data high_five;
do year=2019 to 2020;
do month=1 to 12;
weekday=mdy(month,5,year);
format weekday date9.;
output;
end;
end;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.