If a single step is critical then you need to do it in manual data step. Something like:
data t_ecg3;
length visit $ 32; /*<= need to set the length to hold the longest expected value*/
set t_ecg2 (drop=visit);
array vl ECGRES1 ECGRES2 ECGRES3;
do i=1 to dim (vl);
visit=put(vname(vl[i]),$visit.);
col1= vl[i];
output;
end;
drop i ECGRES1 ECGRES2 ECGRES3;
run;
One of the very likely headaches in the attempt is the assigned length of your visit variable and whether the placing the formatted version in to the variable would fit.
However, assigning the FORMAT to the variable _name_ should work for many purposes.
Note that habitual use of the
data have;
set have;
construct will lead to problems figuring out where your logic problem occurred when something goes unexpected. You completely rewrite the data set and cannot get back to the previous version.
... View more