BookmarkSubscribeRSS Feed
bibbnd
Fluorite | Level 6

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;

 

 

 

1 REPLY 1
andreas_lds
Jade | Level 19

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;
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 592 views
  • 0 likes
  • 2 in conversation