I need to check 3 different variables against blocks of .1 until 1 to see if their prob is greater than the decile.
so i have
w_bfin h_bfin q_bfin id
.75 .15 .1 1
.6589 .2324 .1087 2
.4785 .2850 .2365 3
so if the probability is greater than the decile I will record a 1 otherwise it is a 0.
id 1 wdecile_.1 wdecile_.2 wdecile_.3 wdecile_.4 wdecile_.5 ....wdecile_.7 .... hdecile_.1 hdecile_.2 ---- hdecile1
1 0 0 0 0 0 1 1 0 0
because .75 > .7
I think i can use arrays and do loops..
data test;
set unity;
array d(10) .1;
array r w_bfin -- h_bfin;
array decile(*) ;
retain decile;
do i=1 to dim(r);
if r(i) ge d(i) then decile(i) = 0;
end;
run;
I am not sure how to increment the check and create the variables.
drop i;
Untested:
data test;
set have;
array r w_bfin -- h_bfin;
array decile(10);
do i=1 to dim(r);
do j=1 to dim(decile);
d = j / 10;
decile[j] = r[i] > d;
end;
end;
keep id decile:;
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!
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.