BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jyuen204
Obsidian | Level 7

I have a data table created with 3 field values
Table name = CUST_EMAIL

Fields:

CUSTOMER_ID

BILLING_NUMBER

EMAIL_ADDRESS

 

The Customer_ID is the highest level granularity meaning it can have multiple BILLING_ACCOUNTS. Each Billing account only has 1 email though.

 

I have a rank to pull this data together to provide a ranking

 

proc rank data= CUST_EMAIL out=RANK_RESULTS ties = low descending;
by CUSTOMER_ID;
var BILLING_NUMBER;
ranks EMAIL_RANK ;
run;

 

However when I run the PROC RANK i am getting this error
ERROR: Data set WORK.CUST_EMAIL is not sorted in ascending sequence. The current BY group has CUSTOMER_ID = 1-9990SF and the next BY group has CUSTOMER_ID = 1-9990NY.

 

Even though when I created the table CUST_EMAIL, I had it ordered by CUSTOMER_ID ASC so I am not sure why it is saying that my data set isnt sorted

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You need a PROC SORT before you run PROC RANK. The sort needs to be BY CUSTOMER_ID;

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

You need a PROC SORT before you run PROC RANK. The sort needs to be BY CUSTOMER_ID;

--
Paige Miller
Jyuen204
Obsidian | Level 7

Thanks! That worked. I figured i could sort the data in my table build and it would be good enough.

ballardw
Super User

@Jyuen204 wrote:

I have a data table created with 3 field values
Table name = CUST_EMAIL

Fields:

CUSTOMER_ID

BILLING_NUMBER

EMAIL_ADDRESS

 

The Customer_ID is the highest level granularity meaning it can have multiple BILLING_ACCOUNTS. Each Billing account only has 1 email though.

 

I have a rank to pull this data together to provide a ranking

 

proc rank data= CUST_EMAIL out=RANK_RESULTS ties = low descending;
by CUSTOMER_ID;
var BILLING_NUMBER;
ranks EMAIL_RANK ;
run;

 

However when I run the PROC RANK i am getting this error
ERROR: Data set WORK.CUST_EMAIL is not sorted in ascending sequence. The current BY group has CUSTOMER_ID = 1-9990SF and the next BY group has CUSTOMER_ID = 1-9990NY.

 

Even though when I created the table CUST_EMAIL, I had it ordered by CUSTOMER_ID ASC so I am not sure why it is saying that my data set isnt sorted


Simple solution: Sort the data by the variable on the By statement.

 

You might check to see if any of those id values have leading blanks. You might think they are in "order" but a leading blank can throw that off. The error message though does show the values at the time your run Proc Rank are out of order.

 

Interpretation of a rank on a value like Billing_Account (is that the same as Billing_number?) sounds a tad off if it is anything other than a sequence number of some sort.

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 658 views
  • 0 likes
  • 3 in conversation