BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fayemelissa
Calcite | Level 5
 

 How would I be able to create a code for this without using an sql procedure?

Determine the day of the week (Monday to Friday) for which the total observed usage time during the study period was the highest. The result of your procedure should show the days of week only.

I want to have a table with The weekdays and their total of usage time. To do so I have to calculate the sum of the usage time and exclude the weekend days.There are multiple observations for the usage time per day. This is what I have so far:

PROC SUMMARY DATA=NewBixi;
	VAR Timeusage;
	OUTPUT OUT=Usage SUM=;
	BY Day;
RUN;
PROC PRINT DATA=Usage;
	ID Day;
	WHERE Jour not in("Sunday";"Saturday");
RUN;

However; Saturday still shows in my table and I do not want to have the _type_ and _Freq_ columns in my final table.

 

Thank you for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

Please post the data you have in usable form.

I would expect one date variable to be part of the data, allowing the usage of the format-statement in proc summary to get the required aggregation. To remove unwanted variable, use the keep/drop dataset-option in the output-statement of proc summary. The code is, of course, untested:

proc summary data=have nway;
  class Day;
  var Timeusage;
  format Day weekday.;
  output out=result(drop= _type_ _freq_) sum=;
run;

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Your code will not run. Look at the log.

andreas_lds
Jade | Level 19

Please post the data you have in usable form.

I would expect one date variable to be part of the data, allowing the usage of the format-statement in proc summary to get the required aggregation. To remove unwanted variable, use the keep/drop dataset-option in the output-statement of proc summary. The code is, of course, untested:

proc summary data=have nway;
  class Day;
  var Timeusage;
  format Day weekday.;
  output out=result(drop= _type_ _freq_) sum=;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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