BookmarkSubscribeRSS Feed
Aman4SAS
Obsidian | Level 7

 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.

 

 

 

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

What does your desired output look like?

user24feb
Barite | Level 11
Isn't that what proc sort .. by var1 var2 var3 is doing?
andreas_lds
Jade | Level 19

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

PeterClemmensen
Tourmaline | Level 20

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;

 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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