BookmarkSubscribeRSS Feed
devarayalu
Fluorite | Level 6

Can any one help?

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;

4 REPLIES 4
antony_allianz
Fluorite | Level 6

Give the informat for sales also like 6.2.

antony_allianz
Fluorite | Level 6

give informat to sales as sales:6.2

Tom
Super User Tom
Super User

You need to tell it to sort by the actual value and not the displayed text string's value.

define sales / order order=internal ;

Cynthia_sas
Diamond | Level 26

Hi:

  In addition to Tom's suggestion, depending on what you mean by the "order coming out somewhat wrongly", there are other options you can use in your DEFINE statement. For example, if you want the SALES in DESCENDING order, that is an option you can list on the DEFINE statement. ORDER= can take 4 values: FREQ, FORMATTED, INTERNAL and DATA.  I rarely use FREQ or FORMATTED. I find that either INTERNAL or DATA suits most of what I need to do.

  Here are some other examples to compare.

cynthia

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

;

run;

  

ods listing close;

ods html file='c:\temp\show_order.html' style=sasweb;

proc report data=one nofs;

title '1) ORDER (simple) is ASCENDING';

column cty zip var sales;

define var / display;

define sales / order f=6.2;

run;

    

proc report data=one nofs;

title '2) ORDER (simple) is DESCENDING';

column cty zip var sales;

define var / display;

define sales / order descending f=6.2;

run;

     

     

proc report data=one nofs;

title '3) ORDER is DATA gives input data order';

column cty zip var sales;

define var / display;

define sales / order f=6.2 order=data;

run;

  

proc report data=one nofs;

title '4) ORDER is internal';

column cty zip var sales;

define var / display;

define sales / order f=6.2 order=internal;

run;

  

proc report data=one nofs;

title '5) ORDER for multiple vars note that ZIP is still unordered';

column cty zip var sales;

define cty / order;

define var / display;

define sales / order f=6.2;

run;

  

proc report data=one nofs;

title '6) ORDER for multiple vars DESCENDING for CTY';

column cty zip var sales;

define cty / order DESCENDING;

define var / display;

define sales / order f=6.2;

run;

 

ods html close;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1620 views
  • 0 likes
  • 4 in conversation