BookmarkSubscribeRSS Feed
KemarRoach
Calcite | Level 5

Hello everyone

My worry is about having a deep understanding of  FORMAT

So i m trying to calculate the average within  each range that is created within the format

Following is the code

 

proc format;
value SalesRange 0 - <100000 = 'Lower'
                     100000 - <200000 = 'Middle'
                    200000 - high = 'Upper';
run;

data shoerange;
      set sashelp.shoes;
salesreport = put(sales,SalesRange.);
run;

title" sales report";
proc print data = shoerange;
var sales salesreport;
run;

 

How do i proceed to calculate the average of first range second range and third range

Thanks for your help

2 REPLIES 2
andreas_lds
Jade | Level 19

Looks like something that has been answered last week.

Your proc format has syntax errors ... then replace everything after proc format with

proc means data=sashelp.shoes mean nonobs;
   class Sales;
   var Sales;
   format Sales SalesRange.;
run;

 

PaigeMiller
Diamond | Level 26

Your exact question, with the exact same wording, has already been asked and answered. https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781...

 

In my opinion, a very poorly designed problem.

 

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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