Ranking the Dataset

Reply
Occasional Contributor
Posts: 12

Ranking the Dataset

The purpose is to rank the cust_num and acct_num in the below table due to confidential reason. I am thinking about ordering them into cus_rank and acct_rank. Anyone would be able to give me some advise?

Much appreciated for the help.

 

data have_want;

input cust_num acct_num cus_rank acct_rank;

cards;

123 89 1 1

123 90 1 2

234 95 2 3

345 95 3 3

;

run;

Grand Advisor
Posts: 17,329

Re: Ranking the Dataset

I'm not sure how this helps with confidentiality.  You can look into PROC RANK for starters or can hard code it. Below is an example of hard coding the rules.

 


data want;
set have_want (Drop = cus_rank acct_rank);
lag_cust_num=lag(cust_num);
lag_acct_num =lag(acct_num);

if cust_num ne lag_cust_num then cus_rank+1;

if acct_num ne lag_acct_num then acct_rank+1;

drop lag_:;
run;

 

 

Ask a Question
Discussion stats
  • 1 reply
  • 166 views
  • 0 likes
  • 2 in conversation