Data one;
INPUT ZIP CTY $ VAR :$15. SALES;
CARDS;
52423 Scott Merlot 186.
52423 Scott Chardonnay 156.61
52423 Scott Zinfandel 35.5
52423 Scott Merlot 55.3
52388 Scott Merlot 122.89
52388 Scott Chardonnay 78.22
52388 Scott Zinfandel 15.4
52200 Adams Merlot 385.51
52200 Adams Chardonnay 246
52200 Adams Zinfandel 151.1
52200 Adams Chardonnay 76.24
52199 Adams Merlot 233.03
52199 Adams Chardonnay 185.22
52199 Adams Zinfandel 95.84
;
proc report data=one nofs headline headskip;
column cty zip var sales;
define var / display;
define sales / order;
run;
In order to answer that, the question is "What order do you want to see?"
In looking at your code, I made a couple changes including:
1. Changed VAR to VARIETY --> since using a keyword is usually ill-advised in case it causes issues when running certain procedures.
2. Sorted the data --> so that the data could be sorted in the desired way before reporting
3. Formatted the variables SALES so all sales would show with 2 places after the decimal.
4. Removed the last line in the call to the REPORT procedure since it was not clear what you were trying to do.
5. Reordered the columns in the report (I wasn't sure which order you wanted).
/*** BEGIN REVISED CODE ***/
Data one;
INPUT ZIP CTY $ VARIETY :$15. SALES;
FORMAT SALES 12.2;
CARDS;
52423 Scott Merlot 186.
52423 Scott Chardonnay 156.61
52423 Scott Zinfandel 35.5
52423 Scott Merlot 55.3
52388 Scott Merlot 122.89
52388 Scott Chardonnay 78.22
52388 Scott Zinfandel 15.4
52200 Adams Merlot 385.51
52200 Adams Chardonnay 246
52200 Adams Zinfandel 151.1
52200 Adams Chardonnay 76.24
52199 Adams Merlot 233.03
52199 Adams Chardonnay 185.22
52199 Adams Zinfandel 95.84
;
proc sort data=one out=two;
by descending sales;
run;
proc report data=two nofs headline headskip;
column variety sales cty zip;
define variety / display;
run;
/*** END REVISED CODE ***/
The revised report now creates the following SAS Output sorted in order of descending sales:
VARIETY | SALES | CTY | ZIP |
---|---|---|---|
Merlot | 385.51 | Adams | 52200 |
Chardonnay | 246.00 | Adams | 52200 |
Merlot | 233.03 | Adams | 52199 |
Merlot | 186.00 | Scott | 52423 |
Chardonnay | 185.22 | Adams | 52199 |
Chardonnay | 156.61 | Scott | 52423 |
Zinfandel | 151.10 | Adams | 52200 |
Merlot | 122.89 | Scott | 52388 |
Zinfandel | 95.84 | Adams | 52199 |
Chardonnay | 78.22 | Scott | 52388 |
Chardonnay | 76.24 | Adams | 52200 |
Merlot | 55.30 | Scott | 52423 |
Zinfandel | 35.50 | Scott | 52423 |
Zinfandel | 15.40 | Scott | 52388 |
Hope this helps!
Doug
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!Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.