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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.