BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10
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 

DATEWeekday
05-01-2019Saturday
05-02-2019Tuesday
05-03-2019Tuesday
05-04-2019Friday
05-05-2019Sunday
05-06-2019Wednesday
05-07-2019Friday
05-08-2019Monday
05-09-2019Thursday
05-10-2019Saturday
05-11-2019Tuesday
05-12-2019Thursday
1 ACCEPTED SOLUTION

Accepted Solutions
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @BrahmanandaRao 

 

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;

 

View solution in original post

4 REPLIES 4
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @BrahmanandaRao 

 

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;

 

Jagadishkatam
Amethyst | Level 16
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;
Thanks,
Jag
BrahmanandaRao
Lapis Lazuli | Level 10

Hi

 Jagadish not getting desired output as per 2019 year 

ShiroAmada
Lapis Lazuli | Level 10

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1900 views
  • 0 likes
  • 4 in conversation