- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What if under the FloorAreaCat consist of "None", "Equal" or "Type" variables, can we do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
TYPE 30.52
NONE 25.20
EQUAL 10.45
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.