BookmarkSubscribeRSS Feed
Jyuen204
Obsidian | Level 7

I have a table where I have an IDAGENT_IDAGENT_NAME, TEAM_LEAD_NM, DATE

 

I am trying to use Proc SQL to generate a rank because the ID and NAME are duplicated.

 

proc sql;
select AGENT_ID, AGENT_NAME, TEAM_LEAD_NM, rank() over (Partition by AGENT_LAN_ID
                                                                                                             order by sys_load_dtm desc) as RANK
from TABLE
where AGENT_NAME = 'Smith, John';
run;

 

The error i get is:

____
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

 

 

what is the proper syntac in PROC SQL to rank my data? 

 

Thank you!

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

If you absolutely want to use SQL, you must first sort the data and use the unsupported monotonic() function, and then use that data for subsequent processing.

Feel free to vote here and here to change this, if you think it makes a difference.

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
  • 1 reply
  • 286 views
  • 0 likes
  • 2 in conversation