@weweaw wrote:
Hello,
I want to make indicator variables if the second two digits are a particular set. The variable its self it char. The numbers go from 0-9 for both positions. If it was h678 then I want to make an indicator var to be called _67 (or nit67) and that to be 1. I've been trying to make a do loop but cannot make it work.
This is what I have:
id
nit
234
a019
453
b033
457
c101
And this is what I want:
id
nit
_01
_02
_03
_04
_05
_06
_07
_08
_09
_10
234
a019
1
0
0
0
0
0
0
0
0
0
453
b033
0
0
1
0
0
0
0
0
0
0
457
c101
0
0
0
0
0
0
0
0
0
1
Thank you!
I think you want something similar to:
data want;
set have;
array _ _00-_99;
test=input(substr(nit,2,2),best.);
do i=1 to dim(_);
_[i]= (test+1=i);
end;
drop i;
run;
Your "description" may have missed that you need to have an _00 indicator. If you intended 00 to be _100 you need to state so.
Test is the numeric value of the second and third characters. If that is not a valid number you will get 0 for all indicators.
... View more