DATA Step, Macro, Functions and more

Need help to rank the data

Reply
Super Contributor
Posts: 271

Need help to rank the data

[ Edited ]

 Hi All,

 

I need to rank my data.

 

id var1 var2 var3

1 10      5      24

2 20      7      32

3 30      20     62

4 30      30    98

5 30      30    63

6 40       45    21

7 40       75    33

8 50      60     90 

 

 

My challage is : I need to rank the data base on priotize variable 

example first priority variable is var1  but if var1 is duplicate then need to check var2 if var2 also duplicate then need to check var3

 

priority level is var1 then var2 then var3

 

i would be very thankful for ur help.

 

 

 

PROC Star
Posts: 1,215

Re: Need help to rank the data

What does your desired output look like?

Super Contributor
Posts: 353

Re: Need help to rank the data

Isn't that what proc sort .. by var1 var2 var3 is doing?
Valued Guide
Posts: 522

Re: Need help to rank the data

A look-ahead seems to be the method to solve the problem. Explained here: http://support.sas.com/resources/papers/proceedings10/103-2010.pdf

PROC Star
Posts: 1,215

Re: Need help to rank the data

[ Edited ]

If that is the case then do


data have; input id var1 var2 var3; datalines; 1 10 5 24 2 20 7 32 3 30 20 62 4 30 30 98 5 30 30 63 6 40 45 21 7 40 75 33 8 50 60 90 ; proc sort data=have; by var1-var3; run;

 

Ask a Question
Discussion stats
  • 4 replies
  • 108 views
  • 0 likes
  • 4 in conversation