Hello everyone,
I have attached an Excel file with two tabs
sample input dataset and desired output
I would appreciate your help in helping me write a code to group te data into weeks beginning Sunday and having the desired output
Thankyou
Always (as in ALWAYS) provide example data in data steps with datalines, posted in a code box. Data steps need only a copy/paste and submit to recreate your dataset, while Excel files tell us next to nothing about your dataset(s), as there are no fixed column attributes, and we have to rely on the guessing of PROC IMPORT.
On top of that, Excel files are not accessible from the net for many people as they work behind corporate firewalls that block Office files for security reasons.
The easiest way to tackle your issue is usually to assign a weekly format to your date variable and let the summary/reporting procedures do it automatically.
As I refuse to download file attachments, I agree with @Kurt_Bremser who said "Always (as in ALWAYS) provide example data in data steps with datalines, posted in a code box."
Since SAS has already done the hard work of figuring out what dates are in which weeks, you should definitely use those methods, rather than trying to create your own. The best way is to apply a week format to your calendar variable, and then most analyses in SAS will use the week format to separate results by week.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.