Hello,everyone,
I need your kindly help again.
I have data as below:randid is just ID,each subject has a risk probability.I need to convert these probability to 0-100 scale,generate a new variable represent the risk score for each subject.
Thanks!
Jing
Obs RANDID prob
1 36459 0.09
2 67905 0.07
3 68194 0.14
4 70948 0.33
5 95182 0.22
6 98536 0.27
7 127196 0.18
8 147250 0.40
9 151110 0.27
10 162837 0.14
11 172770 0.09
12 204047 0.11
13 206291 0.09
14 207401 0.40
15 207538 0.22
16 256485 0.18
17 261349 0.27
18 276073 0.22
19 302824 0.09
20 303367 0.11
21 309257 0.18
22 309808 0.18
23 311966 0.40
24 336991 0.14
25 345164 0.07
26 346465 0.14
27 366964 0.40
28 388279 0.09
29 411906 0.40
30 418415 0.14
Hi Jing,
Is this what you want?
data have;
input Obs RANDID prob;
cards;
1 36459 0.09
2 67905 0.07
3 68194 0.14
4 70948 0.33
5 95182 0.22
6 98536 0.27
7 127196 0.18
8 147250 0.40
9 151110 0.27
10 162837 0.14
11 172770 0.09
12 204047 0.11
13 206291 0.09
14 207401 0.40
15 207538 0.22
16 256485 0.18
17 261349 0.27
18 276073 0.22
19 302824 0.09
20 303367 0.11
21 309257 0.18
22 309808 0.18
23 311966 0.40
24 336991 0.14
25 345164 0.07
26 346465 0.14
27 366964 0.40
28 388279 0.09
29 411906 0.40
30 418415 0.14
;
data want;
set have;
new=(prob-0.07)/(0.4-0.07)*100;
proc print;run;
Obs Obs RANDID prob new
1 1 36459 0.09 6.061
2 2 67905 0.07 0.000
3 3 68194 0.14 21.212
4 4 70948 0.33 78.788
5 5 95182 0.22 45.455
6 6 98536 0.27 60.606
7 7 127196 0.18 33.333
8 8 147250 0.40 100.000
9 9 151110 0.27 60.606
10 10 162837 0.14 21.212
11 11 172770 0.09 6.061
12 12 204047 0.11 12.121
13 13 206291 0.09 6.061
14 14 207401 0.40 100.000
15 15 207538 0.22 45.455
16 16 256485 0.18 33.333
17 17 261349 0.27 60.606
18 18 276073 0.22 45.455
19 19 302824 0.09 6.061
20 20 303367 0.11 12.121
21 21 309257 0.18 33.333
22 22 309808 0.18 33.333
The SAS System
Are you just asking how convert a probability (a number between 0 and 1) into a percentage (a number between 0 and 100)?
How about just multiply by 100?
Or are you asking something more complicated? If so I think we more information.
Hi,Tom,
Thanks.
I am asking a more complicated one.Like here,the range is 0.07-0.40,based on the distribution,assign 0-100 scale to each of the corresponding probability.My real data set actually is very large,like more 2000 subjects.
Jing
Hi Jing,
Is this what you want?
data have;
input Obs RANDID prob;
cards;
1 36459 0.09
2 67905 0.07
3 68194 0.14
4 70948 0.33
5 95182 0.22
6 98536 0.27
7 127196 0.18
8 147250 0.40
9 151110 0.27
10 162837 0.14
11 172770 0.09
12 204047 0.11
13 206291 0.09
14 207401 0.40
15 207538 0.22
16 256485 0.18
17 261349 0.27
18 276073 0.22
19 302824 0.09
20 303367 0.11
21 309257 0.18
22 309808 0.18
23 311966 0.40
24 336991 0.14
25 345164 0.07
26 346465 0.14
27 366964 0.40
28 388279 0.09
29 411906 0.40
30 418415 0.14
;
data want;
set have;
new=(prob-0.07)/(0.4-0.07)*100;
proc print;run;
Obs Obs RANDID prob new
1 1 36459 0.09 6.061
2 2 67905 0.07 0.000
3 3 68194 0.14 21.212
4 4 70948 0.33 78.788
5 5 95182 0.22 45.455
6 6 98536 0.27 60.606
7 7 127196 0.18 33.333
8 8 147250 0.40 100.000
9 9 151110 0.27 60.606
10 10 162837 0.14 21.212
11 11 172770 0.09 6.061
12 12 204047 0.11 12.121
13 13 206291 0.09 6.061
14 14 207401 0.40 100.000
15 15 207538 0.22 45.455
16 16 256485 0.18 33.333
17 17 261349 0.27 60.606
18 18 276073 0.22 45.455
19 19 302824 0.09 6.061
20 20 303367 0.11 12.121
21 21 309257 0.18 33.333
22 22 309808 0.18 33.333
The SAS System
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.