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.
I don't know what the function row_number() exactly does, but maybe _n_ is what you are looking for.
data want;
set have;
by member_key;
if first.member_key
then counter = 1;
else counter + 1;
run;
but in Row_Number() there are several columns which are cimbined in CustRank column
Please supply source data in usable form (data step with datalines), and what you expect out of it.
@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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.