Well, the simple answer is normalise your data:
proc transpose data=have out=want;
by id;
var day:;
run;
data want;
set want;
where _result_ ne .;
run;
/* And then if you have to transpose again */
proc transpose data=want out=t_want;
by id;
var _result_;
run;
You will find 99% of programming tasks are easier with normalised data. The only time to use transposed data is in an actual repotr file - i.e. at the time of proc report. At any other programming moment, by group processing is far simpler to code, and maintain, and uses less resources. The alternative is a messy, harder to maintain array type coding (which of course you woul need to do again and again for each step):
data want;
set have;
array day{10};
array var{10} 8;
j=1;
do i=1 to 10;
if day{i} ne . then do;
var{j}=day{i};
j=j+1;
end;
end;
run;
Now the code doesn't look too bad for that one check, but you need to know how many var values are used, and how many day values are up front etc. Makes code harder to maintain.
... View more