Reputation: 1145
I've the following the data structure
ID Y xx11 xx12 xx13 xx14 xx21 xx22 xx23 xx24 xx31 xx32 xx33 xx34 xx41 xx42 xx43 xx44;
Where Y is the response variable and x's are the covariates.
I need to manipulate the data using "Array" command in SAS to produce the following data set:
ID Y Time Group
Thanks.
Upvotes: 0
Views: 188
Reputation: 63424
data want;
set have;
array xx xx11--xx44;
do _t = 1 to dim(xx);
x=xx[_t];
group = substr(vname(xx[_t]),3,1);
time = substr(vname(xx[_t]),4,1);
output;
end;
run;
This depends on xx11 through xx44 being consecutive variables (not in any particular order).
Upvotes: 3