Hi, I'm learning SAS and I have a very slow learning curve... I'm getting frustrated :smileysilly: I have the variable Cow, with that kind of observations : Cow 1 2 3 3 3 3 3.4 4 2.3 1.2.3 3 3 What I'd like to do is to create a new varibales: Cow_1 Cow_2 Cow_3 Cow_4 and code, 0 or 1 for each observation according to original observations under the variable cow. So here is what I tried, but it doesn't work.... I get 0 everywhere : Data librairy.new; set librairy.old; Cow_1=0; Cow_2=0; Cow_3=0; Cow_4=0; do i = 1 to 4; if substr(Cow, i, 1)= 1 then Cow_1= 1; if substr(Cow, i, 1)= 2 then Cow_2= 1; if substr(Cow, i, 1)= 3 then Cow_3= 1; if substr(Cow, i, 1)= 4 then Cow_4= 1; end; run; Help please !!!!!
... View more