BookmarkSubscribeRSS Feed
Baba9
Obsidian | Level 7

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 

 

2 REPLIES 2
Kurt_Bremser
Super User

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.

 

PaigeMiller
Diamond | Level 26

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.

 

 

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 404 views
  • 0 likes
  • 3 in conversation