BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jing2000yr
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

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.

jing2000yr
Calcite | Level 5

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

Linlin
Lapis Lazuli | Level 10

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

Keith
Obsidian | Level 7

PROC STDIZE can do this for you, which saves hard coding the minimum / maximum values.

(uses data set created by )

proc stdize data=have out=want method=range mult=100;

var prob;

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 5727 views
  • 6 likes
  • 4 in conversation