DATA Step, Macro, Functions and more

Sorting within Group

Reply
New Contributor
Posts: 3

Sorting within Group

Hi I am trying to create a report from a sorted dataset ( Grp_Order - Ascending & Total_Paid - Descending).  The only parts that are sorted correctly are the odd # breaks.  I tried variations of order = internal, order = data on the sorted variables.  Here is the code.

 

proc report data=WORK.UTILIZATION_DATA_ORDER nowd

style(header) =

[just = left

font_face = calibri

font_size = 3

foreground = white

background = teal

protectspecialchars=off] ;

column Groupm Service_Category CHARGE_AMOUNT DISALLOW_AMOUNT ALLOWED_AMOUNT DISCOUNT_AMOUNT BENEFIT_AMOUNT DEDUCTIBLE_AMOUNT COPAY_AMOUNT COB_AMOUNT COINSURANCE_AMOUNT TOTAL_PAID Paid_Count Discount_Percent;

WHERE Current_Period = 'X';

define Groupm / order ORDER=data noprint;

define Service_Category / order ORDER=data 'Service Category' style(column)=[asis=on] missing style={just=l vjust =b };

break after Groupm / ol summarize page;

rbreak before / summarize;

compute Service_Category;

if _break_='_RBREAK_' then do;

Service_Category='Grand Total';

call define(_row_, 'style', 'style=[font_weight=bold color = white background = grey]');

end;

else if upcase(_break_)="GROUPM" then do;

Service_Category=Groupm;

call define(_row_, 'style', 'style=[font_weight=bold color = white background = grey]');

end;

else Service_Category = ' ' || Service_Category;

endcomp;

 

define CHARGE_AMOUNT / analysis SUM 'Charges' format=DOLLAR16.0 missing style={just=c vjust=b};

define DISALLOW_AMOUNT / analysis SUM 'Disallowed' format=DOLLAR16.0 missing style={just=c vjust=b};

define ALLOWED_AMOUNT / analysis SUM 'Allowed' format=DOLLAR16.0 missing style={just=c vjust=b};

define DISCOUNT_AMOUNT / analysis SUM 'Discount' format=DOLLAR16.0 missing style={just=c vjust=b};

define BENEFIT_AMOUNT / analysis SUM 'Benefit' format=DOLLAR16.0 missing style={just=c vjust=b};

define DEDUCTIBLE_AMOUNT / analysis SUM 'Deductible' format=DOLLAR16.0 missing style={just=c vjust=b};

define COPAY_AMOUNT / analysis SUM 'Co-Pay' format=DOLLAR16.0 missing style={just=c vjust=b};

define COB_AMOUNT / analysis SUM 'COB' format=DOLLAR16.0 missing style={just=c vjust=b};

define COINSURANCE_AMOUNT / analysis SUM 'Coinsurance' format=DOLLAR16.0 missing style={just=c vjust=b};

define TOTAL_PAID / analysis SUM 'Plan Payment' order=data format=DOLLAR16.0 missing style={just=c vjust=b};

define Paid_Count / analysis SUM 'Paid Count' format=Comma14.0 missing style={just=c vjust=b};

define Discount_Percent / computed 'Disc. %' format=PERCENT7.1 missing style={just=c vjust=b};

compute Discount_Percent;

Discount_Percent= DISCOUNT_AMOUNT.sum / ALLOWED_AMOUNT.sum;

endcomp;

 

run;

quit;

 

Appreciate any help...thanks in advance..

Valued Guide
Posts: 797

Re: Sorting within Group

Please show us a sample of the result, pointing out the part which is not wanted.

New Contributor
Posts: 3

Re: Sorting within Group

On the attached, page 1 is sorted by plan payment (Total_Paid) in descending order.  But page 2 is not.  Page 3 is sorted correctly, but page 4 is not. 

Ask a Question
Discussion stats
  • 2 replies
  • 114 views
  • 0 likes
  • 2 in conversation