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

Hi Guys ,

I want dates for all sundays in a year

 

using data step and proc step

 

 

Regards,

ANAND

1 ACCEPTED SOLUTION

Accepted Solutions
BrahmanandaRao
Lapis Lazuli | Level 10

Thank your very much 

 

 

 

 

Regards,

Anand

View solution in original post

8 REPLIES 8
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Date formats is what you are looking for.

https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm

 

to find Sundays, use weekday.

 

PeterClemmensen
Tourmaline | Level 20

For 2019

 

data AllSundays;
   do date='01jan2019'd to '31dec2019'd;
      if weekday(date)=1 then output;
   end;
   format date date9.;
run;
BrahmanandaRao
Lapis Lazuli | Level 10

Thank your very much 

 

 

 

 

Regards,

Anand

BrahmanandaRao
Lapis Lazuli | Level 10

Hi 

I want to create separate  flag variable weekday column along witth date this same code how it is?

 

ObsdateWeekday
107-Jan-19Sunday
214-Jan-19Sunday
321-Jan-19Sunday
428-Jan-19Sunday
504-Feb-19Sunday
611-Feb-19Sunday
718-Feb-19Sunday
825-Feb-19Sunday
904-Mar-19Sunday
1011-Mar-19Sunday
1118-Mar-19Sunday
1225-Mar-19Sunday
1301-Apr-19Sunday
1408-Apr-19Sunday
1515-Apr-19Sunday
1622-Apr-19Sunday
1729-Apr-19Sunday
1806-May-19Sunday
1913-May-19Sunday
2020-May-19Sunday
2127-May-19Sunday
2203-Jun-19Sunday
2310-Jun-19Sunday
2417-Jun-19Sunday
2524-Jun-19Sunday
2601-Jul-19Sunday
2708-Jul-19Sunday
2815-Jul-19Sunday
2922-Jul-19Sunday
3029-Jul-19Sunday
3105-Aug-19Sunday
3212-Aug-19Sunday
3319-Aug-19Sunday
3426-Aug-19Sunday
3502-Sep-19Sunday
3609-Sep-19Sunday
3716-Sep-19Sunday
3823-Sep-19Sunday
3930-Sep-19Sunday
4007-Oct-19Sunday
4114-Oct-19Sunday
4221-Oct-19Sunday
4328-Oct-19Sunday
4404-Nov-19Sunday
4511-Nov-19Sunday
4618-Nov-19Sunday
4725-Nov-19Sunday
4802-Dec-19Sunday
4909-Dec-19Sunday
5016-Dec-19Sunday
5123-Dec-19Sunday
5230-Dec-19Sunday

 

 

PeterClemmensen
Tourmaline | Level 20

You can either do this with a simple format like this

 

data AllSundays;
   do date='01jan2019'd to '31dec2019'd;
      Weekday=date;
      if weekday(date)=1 then output;
   end;
   format Weekday downame. date date9.;
run;

or like below if you want Weekday to be a character variable.

 

data AllSundays;
   do date='01jan2019'd to '31dec2019'd;
      Weekday=put(date, downame. -l);
      if weekday(date)=1 then output;
   end;
   format date date9.;
run;
BrahmanandaRao
Lapis Lazuli | Level 10

Hi Draycut

Thank your for solution

 

Obs date 
06JAN2019Sunday
13JAN2019Sunday
20JAN2019Sunday
27JAN2019Sunday
03FEB2019Sunday
10FEB2019Sunday
17FEB2019Sunday
24FEB2019Sunday
03MAR2019Sunday
10MAR2019Sunday
17MAR2019Sunday
24MAR2019Sunday
31MAR2019Sunday
07APR2019Sunday
14APR2019Sunday
21APR2019Sunday
28APR2019Sunday
05MAY2019Sunday
12MAY2019Sunday
19MAY2019Sunday
26MAY2019Sunday
02JUN2019Sunday
09JUN2019Sunday
16JUN2019Sunday
23JUN2019Sunday
30JUN2019Sunday
07JUL2019Sunday
14JUL2019Sunday
21JUL2019Sunday
28JUL2019Sunday
04AUG2019Sunday
11AUG2019Sunday
18AUG2019Sunday
25AUG2019Sunday
01SEP2019Sunday
08SEP2019Sunday
15SEP2019Sunday
22SEP2019Sunday
29SEP2019Sunday
06OCT2019Sunday
13OCT2019Sunday
20OCT2019Sunday
27OCT2019Sunday
03NOV2019Sunday
10NOV2019Sunday
17NOV2019Sunday
24NOV2019Sunday
01DEC2019Sunday
08DEC2019Sunday
15DEC2019Sunday
22DEC2019Sunday
29DEC2019Sunday
PeterClemmensen
Tourmaline | Level 20

@BrahmanandaRao, please mark my solution as accepted and not your own 🙂

 

This helps future users navigate the forum.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 4122 views
  • 2 likes
  • 4 in conversation