BookmarkSubscribeRSS Feed
Son_Of_Krypton
Fluorite | Level 6

I have following sql code that i want to do it in sas datastep.

 

ROW_NUMBER() OVER(PARTITION BY member_key ORDER BY 
joindate asc, (case when status='Existing' then 1 when Status='Pending' then 2 else 3 end) asc,
savings desc) as CustRank

How we can do this in sas datastep need some help here.. It would be great if anyone post solution here with example.

 

5 REPLIES 5
andreas_lds
Jade | Level 19

I don't know what the function row_number() exactly does, but maybe _n_ is what you are looking for.

Son_Of_Krypton
Fluorite | Level 6

but in Row_Number() there are several columns which are cimbined in CustRank column

ballardw
Super User

@Son_Of_Krypton wrote:

but in Row_Number() there are several columns which are cimbined in CustRank column


Which leads to more variables on the BY statement and modifications to first.logic.

 

Really need to provide examples of your data and expected results. I have no access to any SQL with this (mythical to me) Row_number function or "Partition over" operation so cannot tell what you expect in any case.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2712 views
  • 0 likes
  • 4 in conversation