BookmarkSubscribeRSS Feed
112211
Obsidian | Level 7

Question : Find weekday for every year from 15aug1940 to now(today) ??

output
August 15, 1940: Thursday
August 15, 1941: Friday
August 15, 1942: Saturday
August 15, 1943: Sunday
August 15, 1944: Tuesday
August 15, 1945: Wednesday
... (continuing for each year up to the current year)

 

 

3 REPLIES 3
MarkusWeick
Barite | Level 11

Hi @112211, you could use the mod function to to get the remainder from the division of the date (an integer number in SAS) by 7. If the remainder is negative you have to add 7. Each of the seven positive possible remainders correspond to a weekday. 

Hope, this helps.

Best, Markus

Please keep the community friendly.
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
Kurt_Bremser
Super User

Use the MDY function to build the SAS dates. Then either use the WEEKDAY function to retrieve the weekday in numeric fashion, or use the DOWNAME format to display the weekday name.

Quentin
PROC Star

Please show the code you have tried, so that we can help you improve it.  In addition to the suggestions from others, you might want to use the INTNX function for advancing the date by a year at a time.

Check out the Boston Area SAS Users Group (BASUG) video archives: https://www.basug.org/videos.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 204 views
  • 1 like
  • 4 in conversation