Functions are used in a data step or PROC SQL, not in other PROCS.
If you review the documentation for WEEKDAY() it returns 1-7, with 1/7 being weekends so you can classify your dates. Then you can separate them. I'm not sure why you need to sort.
1. Create a new variable using the WEEKDAY function to get the weekday
2. Create another new variable that shows if it's a weekend or weekday
Why do you need separate data steps? It's unlikely you actually do need a separate data sets.
set have; *this should be your input data set;
weekDayNumber = weekday(date); *get weekday;
If weekDayNumber in (1, 7) then weekDayType='Weekend';
else if weekDayNumber in (2:6) then weekDayType='Weekday';
*Check coding is correct;
proc freq data=identify_weekday;
*See summaries by weekdayType;
proc means data=identify_weekday;
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.