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

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

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