DATA Step, Macro, Functions and more

determining weekdays character variable

Accepted Solution Solved
Reply
Contributor
Posts: 62
Accepted Solution

determining weekdays character variable

I have a character variable internship_date in the following format (20000130) and would like to get the week days?

Any ideas? Thanks


Accepted Solutions
Solution
‎05-18-2016 09:09 PM
Super User
Posts: 7,766

Re: determining weekdays character variable

Posted in reply to archibald

First, convert the character variable to a SAS date:

internship_date_d = input(internship_date,yymmdd8.);

Then, either use the weekday() function to obtain a number (0..6) that identifies the weekday, or use the weekday. format to display teh same number.

Or use the downame. format to display the English names of the weekdays.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎05-18-2016 09:09 PM
Super User
Posts: 7,766

Re: determining weekdays character variable

Posted in reply to archibald

First, convert the character variable to a SAS date:

internship_date_d = input(internship_date,yymmdd8.);

Then, either use the weekday() function to obtain a number (0..6) that identifies the weekday, or use the weekday. format to display teh same number.

Or use the downame. format to display the English names of the weekdays.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 62

Re: determining weekdays character variable

Posted in reply to KurtBremser

You saved the day! thank you very much!

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 370 views
  • 4 likes
  • 2 in conversation