DATA Step, Macro, Functions and more

How to extract all Saturday's dates from one particular Month ?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

How to extract all Saturday's dates from one particular Month ?

Hi Experts,

Could you please suggest me I want extract all Saturday's dates  from one beginning date of the month till last date of the same month.

So that I can automate the SAS Job. Right Now manually we are passing values,but going forward it has to be automate.

 

For example:

If creating Macro variable

%let sub_table_date='01MAR2018'd

I need to extract all Saturdays date till 31 Mar 2018. (endpoint we have to automate.)

so that we can extract 03Mar, 10Mar,17Mar,24mar,31mar.

 

Regards,

Purna

 

 

 


Accepted Solutions
Solution
‎03-26-2018 04:18 AM
PROC Star
Posts: 1,190

Re: How to extract all Saturday's dates from one particular Month ?

Do something like this.

 

data want;
	sub_table_date='01MAR2018'd;
	end_date=intnx('month', sub_table_date, 0, 'e');

	do date=sub_table_date to end_date;
		if weekday(date)=7 then output;
	end;

	format date date9.;
	keep date;
run;

 

 

View solution in original post


All Replies
Solution
‎03-26-2018 04:18 AM
PROC Star
Posts: 1,190

Re: How to extract all Saturday's dates from one particular Month ?

Do something like this.

 

data want;
	sub_table_date='01MAR2018'd;
	end_date=intnx('month', sub_table_date, 0, 'e');

	do date=sub_table_date to end_date;
		if weekday(date)=7 then output;
	end;

	format date date9.;
	keep date;
run;

 

 

Occasional Contributor
Posts: 14

Re: How to extract all Saturday's dates from one particular Month ?

Much appreciated your quick help.
PROC Star
Posts: 1,190

Re: How to extract all Saturday's dates from one particular Month ?

Anytime, glad to help.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 113 views
  • 2 likes
  • 2 in conversation