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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 2037 views
  • 0 likes
  • 4 in conversation