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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 1 reply
  • 357 views
  • 0 likes
  • 2 in conversation