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

I am working with time use data. 3 Days have been tracked. I'd like to get the total time spent on those three days on each activity.

 

my data looks something like this:

id| activity1 |activity5 |activity6 |activity761 |quarter

160 0 0 03
1
50
0003
100003
21003002
21003002
200052
300054
300054

 

 I'd like a result something like this:

 

id |activity1 |activity5| activity6 |activity761 |quarter

11000003
22006052
3000104

 

somewhere else on this board I found code working for my usecase, but it is very slow, also SAS Student edition warns me no to show the output.

 

proc means data = timeuse nway;
class id;
var activity1  activity5  activity6 activity761;
output out=timeuse_added sum =;
run;

Any suggestions on how to speed up this step? (to keep the quarters I managed to merge the old dataset by id)

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
Turn off the printed output. Use PROC statement option NOPRINT or use PROC SUMMARY. Same mostly but no printed output.

View solution in original post

5 REPLIES 5
data_null__
Jade | Level 19
Turn off the printed output. Use PROC statement option NOPRINT or use PROC SUMMARY. Same mostly but no printed output.
Reeza
Super User

How many observations do you have? Why do you need PROC MEANS to run faster, and what do you consider slow?

I made two changes to your code below. If you presort and switch to a BY instead of CLASS it may be faster if this isn’t fast enough. 


@asdf0990 wrote:

I am working with time use data. 3 Days have been tracked. I'd like to get the total time spent on those three days on each activity.

 

my data looks something like this:

id| activity1 |activity5 |activity6 |activity761 |quarter

1 60  0  0  0 3
1
50
0 0 0 3
1 0 0 0 0 3
2 10 0 30 0 2
2 10 0 30 0 2
2 0 0 0 5 2
3 0 0 0 5 4
3 0 0 0 5 4

 

 I'd like a result something like this:

 

id |activity1 |activity5| activity6 |activity761 |quarter

1 100 0 0 0 3
2 20 0 60 5 2
3 0 0 0 10 4

 

somewhere else on this board I found code working for my usecase, but it is very slow, also SAS Student edition warns me no to show the output.

 

proc means data = timeuse nway noprint;
class id;
var activity1  activity5  activity6 activity761;
output out=timeuse_added sum = / auto name autolabel;
run; out 

Any suggestions on how to speed up this step? (to keep the quarters I managed to merge the old dataset by id)


 

asdf0990
Fluorite | Level 6

@Reeza wrote:

How many observations do you have? Why do you need PROC MEANS to run faster, and what do you consider slow?



 


I have 32105 rows and 705 variables in the dataset. I want to add up about 100 variable values. I consider 5 minutes for that step slow, given that I want to 20x the amount of calculations to be done.

 

thank you for the tips, I sorted allready, will look into the rest

Reeza
Super User
Make sure to increase the cores available to SAS UE in the VirtualBox settings, to 2. You can also increase the RAM that would help, but to be honest, SAS UE is not designed for this type of work. It's for learning mostly. You could try using a full edition if you have access or using SAS AoD.
asdf0990
Fluorite | Level 6
using noprint did increase the calculation speed substantially, all good now.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 1216 views
  • 2 likes
  • 3 in conversation