BookmarkSubscribeRSS Feed
Sanjay_M
Obsidian | Level 7

Please help me with a PROC SUMMARY (only) statement to get the volume by category, weighted volume by category, mean of score by category.

 

Reason I want to use PROC SUMMARY is because I have other code using the same and PROC SUMMARY produces other metrics.

 

data test;

length category score wt 8;

input category score wt;

infile datalines dlm=",";

datalines;

 

1,67,2

1,50,5

1,55,6

2,56,6

2,68,5

3,70,5

4,73,8

run;

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

A couple of questions:

  • which variable is "volume"?
  • when you say you want to get the volume by category, is this a sum or a mean or something else?
  • when you want weighted volume, what variable does the weighting (and do you want the sum or the mean or something else)?
--
Paige Miller
Sanjay_M
Obsidian | Level 7

 

  • which variable is "volume"? Category is segment, so I want volume and weighted volume by category
  •  
  • when you say you want to get the volume by category, is this a sum or a mean or something else? Count by category
  •  
  • when you want weighted volume, what variable does the weighting (and do you want the sum or the mean or something else)? Column is weight

 

 

Sanjay_M
Obsidian | Level 7

Can the admin please move this post to the Statistical group

PaigeMiller
Diamond | Level 26
proc summary data=have;
    class category;
    var wt score;
    output out=stats mean(score)=score_mean sum(wt)=wt_volume;
run;
     

The variable _FREQ_ is the unweighted volume.

   

--
Paige Miller

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!

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
  • 4 replies
  • 750 views
  • 0 likes
  • 2 in conversation