The problem is that you use a character function, substr, on number. So you need to left justify the number, which is automatically converted to a character variable by the substr function, to get the substr function to fetch the first character of the previous number: Data new; set a; Cow_1=0; Cow_2=0; Cow_3=0; Cow_4=0; do i = 1 to 4; if substr(left(Cow), i, 1)= 1 then Cow_1= 1; if substr(left(Cow), i, 1)= 2 then Cow_2= 1; if substr(left(Cow), i, 1)= 3 then Cow_3= 1; if substr(left(Cow), i, 1)= 4 then Cow_4= 1; end; run; If you do not use the left function substring will see e.g. the number 3.4 as the string " 3.4" as 3.4 is converted to the string format $12, thus it will always only fetch a space " " with substr. I reckon that you still do not attempt to get the output from the program that you really want. But that would need a precise formulation of your purpose. Regards PH Krogh
... View more