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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.