BookmarkSubscribeRSS Feed
BabyWS2001
Calcite | Level 5

Hi,
If I have a list of saleprice, but I need to get the mean of it (in ascending order) and categories under One variable FloorAreaCat. How do I write the code in Single Proc means step? (p/s I do not want to use Proc sort step in this case)
Appreciate if can help.

 

Thanks!

17 REPLIES 17
Reeza
Super User
AFAIK this isn't possible, without an additional step. If you're working with a single variable consider using PROC SQL instead.
BabyWS2001
Calcite | Level 5

What if under the FloorAreaCat consist of "None", "Equal" or "Type" variables, can we do it?

Reeza
Super User
AFAIK there's no way to sort based on the value of the MEAN. I'm not sure what the values of FloorAreaCat have to do with that.
Reeza
Super User
proc sql;
create table want as
select make, mean(msrp) as avg_msrp format=8.1
from sashelp.cars
group by make /*BY or CLASS variables go here and in the SELECT statement*/
order by calculated avg_msrp ;
quit;
KachiM
Rhodochrosite | Level 12
Do you want like:
TYPE 30.52
NONE 25.20
EQUAL 10.45
BabyWS2001
Calcite | Level 5

How about the below? Can I sort the Mean in ascending order? I have already found the Mean value of my saleprice, and group it under the FlorrAreaCat but I can't seem to sort the Mean value. Can it be done under the same Proc Means Step?

 

FloorAreaCat   N Obs    Mean (SalePrice)

Equal                200       200000

None                800       150000

Small                 90        340000

Reeza
Super User

@BabyWS2001 wrote:

How about the below? Can I sort the Mean in ascending order? I have already found the Mean value of my saleprice, and group it under the FlorrAreaCat but I can't seem to sort the Mean value. Can it be done under the same Proc Means Step?

 

FloorAreaCat   N Obs    Mean (SalePrice)

Equal                200       200000

None                800       150000

Small                 90        34000


That's DESCENDING order......

PaigeMiller
Diamond | Level 26

Any problem that says you can't use PROC SORT to get things properly sorted seems like it's a made up problem.

--
Paige Miller
KachiM
Rhodochrosite | Level 12

For your special requirements, entire thing can be done in a data step. No need for Proc Sort, Proc Means.

Do you like a data step?

ballardw
Super User

Provide a small example data set and what the result needs to look like.

Write a data step to provide the example data or Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

Any artificial restriction of "cannot use Proc sort" is similar to "I want to eat canned food without opening the can".

BabyWS2001
Calcite | Level 5

Is ok, cause this is my Uni SAS programing assignment question. Will try to find a way out if there no way to solve this question.

 

Thanks.

Reeza
Super User
Post the exact question then, there's the possibility you're misinterpreting the question.
BabyWS2001
Calcite | Level 5

Here the  question

(q) list down in ascending order the mean sale price, categories under variable of FloorAreaCat. Use single Proc Means step to answer this question.

 

Reeza
Super User

A single PROC MEANS doesn't mean you can't use SORT in my opinion. Or maybe there is a way...I would check your class notes.

 


@BabyWS2001 wrote:

Here the  question

(q) list down in ascending order the mean sale price, categories under variable of FloorAreaCat. Use single Proc Means step to answer this question.

 


 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 17 replies
  • 2120 views
  • 0 likes
  • 5 in conversation