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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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