BookmarkSubscribeRSS Feed
sas_learner_NEW
Fluorite | Level 6

Dear community, As a beginner in this community I would request a help. is the code for the question

" What is the mean value of the Sales variable for observations in the “Middle” group? Round
your answer to the nearest whole number. " correct or please suggest any modification.

 

proc means data= work.shoesrange nolabels mean;
class salesrange;
run;

 

 

 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

I can't see your data, so I can only guess that the "Middle" group is in the salesrange variables. 

 

In that case, yes, your code is fine and will give you the mean value for the "Middle" group in the Results Viewer.

 

You could specify the MAXDEC Option in the Proc Means Statement to specify the desired number of decimals.

Kurt_Bremser
Super User

Since you only want one group, you should restrict the observations to that group.

You also want only one variable averaged, so you should tell the procedure that.

proc means data=shoesrange nolabels mean;
where salesrange = "Middle"; /* if "Middle" is in fact the result of a custom format applied to salesrange, this must be adapted */
var sales;
run;

Alternatively, you can use SQL:

proc sql;
select avg(sales) as average_sales
from shoesrange
where salesrange = "Middle";
quit;
sas_learner_NEW
Fluorite | Level 6

thanks

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!

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
  • 3 replies
  • 643 views
  • 0 likes
  • 3 in conversation