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
SAS Super FREQ

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 791 views
  • 0 likes
  • 4 in conversation