turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- BI
- /
- Enterprise Guide
- /
- Sort Mean in Ascending order without Proc Sort

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-22-2017 11:30 AM

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!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 11:36 AM

AFAIK this isn't possible, without an additional step. If you're working with a single variable consider using PROC SQL instead.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

08-22-2017 11:39 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 11:49 AM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

08-22-2017 11:58 AM

```
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;
```

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 11:53 AM

Do you want like:

TYPE 30.52

NONE 25.20

EQUAL 10.45

TYPE 30.52

NONE 25.20

EQUAL 10.45

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to datasp

08-22-2017 11:58 AM - edited 08-22-2017 12:00 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 11:59 AM - edited 08-22-2017 11:59 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

08-22-2017 12:08 PM

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 12:19 PM

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?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 11:58 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 12:28 PM - edited 08-22-2017 12:29 PM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 12:35 PM

Post the exact question then, there's the possibility you're misinterpreting the question.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

08-22-2017 01:03 PM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BabyWS2001

08-22-2017 01:04 PM - edited 08-22-2017 01:07 PM

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.