Hi @ballardw. Thanks for your reply.Yes, I should have known to display my data in a form that can be tested. Also, I realized after that proc sql will require me to transpose the data as count will not be applicable to multiple columns.
I wanted to avoid that. If possible, I would like to use the sum function. I anyways have to convert the values of period1 to period5 to numeric. I also have blanks in the data that have to be converted into missing numeric values. So on a clean slate here is my data and a data manipulation question as well. The values of interest to me are 'in_target'. The other values are 'low' and 'high' which are the 'event vaues not of interest'. 'missing' and blank values both need to be treated as 'missing'.
data have; input id period1 period2 period3 period4 period5
datalines;
1 in_target
2 in_target missing low in_target
3 high high missing missing missing
4 low in_target in_target in_target in_target
run;
I am looking to convert the values of in_target to 1 , low and high as '0' ,missing and blank with a 'period'.
I used the array
array ch(*) $ period:;
array nu(*) periodnew:;
do i = 1 to dim(ch);
if ch(i)='in_target' then do;
nu(i)=1;
end;
else if ch(i)='low' then do;
nu(i)=0;
end;
else if ch(i)='high' then do;
nu(i)=0;
end;
else if ch(i)='missing' then do;
nu(i)=.;
end;
else if ch(i)=' ' then do;
nu(i)=.;
end;
end;
run;
I am getting an error stating
ERROR: Array subscript out of range at line # column #
Could you first please tell me what is wrong with my array code?
... View more