BookmarkSubscribeRSS Feed
PavanKumar2
Fluorite | Level 6

Hi,

I have 2Dates.

Start-Date:01-01-2019

End-Date:01-02-2019

 

I need weekend dates between Start-Date and End-Date as

04-01-2019

11-01-2019

18-01-2019

25-01-2019

01-02-2019

 

Colud you please Help me

 

3 REPLIES 3
FredrikE
Rhodochrosite | Level 12

Try this 🙂

 

data _null_;
 do i = '01jan2019'd to '01feb2019'd;
   if weekday(i) = 6 then put i yymmdd10.;
 end;
run;

//Fredrik

Patrick
Opal | Level 21

@PavanKumar2 

If this is about shifting week-end dates to the date of the previous Friday then below code should do.

data sample;
 format calendar_date workingDate yymmdd10.;
 do calendar_date = '01jan2019'd to '01feb2019'd;
   workingDate=intnx('weekday',calendar_date,0,'b');
   output;
 end;
run;
proc print data=sample;
run;
Ksharp
Super User
data x;
do i=0 to intck('week','01jan2019'd, '01feb2019'd);
  date=intnx('week.7','01jan2019'd,i,'e');output;
end;
format date ddmmyy10.;
run;
proc print;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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1082 views
  • 0 likes
  • 4 in conversation