Hi, i need help in creating a new column which will be used to assign scores based on the below bands:
if qa_score < 90 then Score = 0
if qa_score >= 90 and qa_score < 92.5 then Score = 0.04
if qa_score >= 92.5 and qa_score < 95 then Score = 0.08
if qa_score >= 95 and qa_score < 97.5 then Score = 0.12
if qa_score >= 97.5 and qa_score < 100 then Score = 0.16
if qa_score = 100 then Score = 0.20
data have;
input policy_no QA_score;
datalines;
1 88
2 91
3 94
4 96
5 99
6 100
;
data WANT
policy_no Score
1 0
2 0.04
3 0.08
4 0.12
5 0.16
6 0.20
Try this
proc format;
invalue s
low -< 90 = 0
90 -< 92.5 = 0.04
92.5 -< 95 = 0.08
95 -< 97.5 = 0.12
97.5 -< 100 = 0.16
100 - high = 0.2
;
run;
data have;
input policy_no QA_score;
datalines;
1 88
2 91
3 94
4 96
5 99
6 100
;
data want;
set have;
score = input(QA_score, s.);
run;
Sorry, but i don't see the problem. You have already posted the necessary statements to create the variable "score", so: what is the problem?
Using a format instead of if-statements is recommended, but this is up to you.
Try this
proc format;
invalue s
low -< 90 = 0
90 -< 92.5 = 0.04
92.5 -< 95 = 0.08
95 -< 97.5 = 0.12
97.5 -< 100 = 0.16
100 - high = 0.2
;
run;
data have;
input policy_no QA_score;
datalines;
1 88
2 91
3 94
4 96
5 99
6 100
;
data want;
set have;
score = input(QA_score, s.);
run;
Anytime.
If you want to make it shorter, you can use the following code.
data want;
set have;
if qa_score < 90 then Score = 0;
else if qa_score < 92.5 then Score = 0.04;
else if qa_score < 95 then Score = 0.08;
else if qa_score < 97.5 then Score = 0.12;
else if qa_score < 100 then Score = 0.16;
else if qa_score = 100 then Score = 0.20;
drop qa_score;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.