Hi!
I have 2 columns with ratings A-K. One column is "incoming" rating (IB) of a period and the other "outgoing" (OB).
I'm looking to create a new column based on several conditions:
0 if no change during the period
1 if moved up 1 class, 2 if moved up 2 classes etc
-1 if moved down 1 class, 2 if moved down 2 classes etc
How would one go about accomplishing this without creating one hundred case when lines?
Thank you very much 🙂
I'm looking to create a new column based on several conditions:
0 if no change during the period
1 if moved up 1 class, 2 if moved up 2 classes etc
-1 if moved down 1 class, 2 if moved down 2 classes etc
How would one go about accomplishing this without creating one hundred case when lines?
Create new variables where the letters A, B, ... K are replaced by numbers and then the moving up or moving down is computed by subtraction. You can use the RANK function to obtain the numerical equivalent of A, B, ... K in the ASCII collating sequence; that's all you need.
data want;
set have;
ib_rank=rank(ib);
ob_rank=rank(ob);
change=ob_rank-ib_rank;
run;
I'm looking to create a new column based on several conditions:
0 if no change during the period
1 if moved up 1 class, 2 if moved up 2 classes etc
-1 if moved down 1 class, 2 if moved down 2 classes etc
How would one go about accomplishing this without creating one hundred case when lines?
Create new variables where the letters A, B, ... K are replaced by numbers and then the moving up or moving down is computed by subtraction. You can use the RANK function to obtain the numerical equivalent of A, B, ... K in the ASCII collating sequence; that's all you need.
data want;
set have;
ib_rank=rank(ib);
ob_rank=rank(ob);
change=ob_rank-ib_rank;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.