options ls=90; filename foo2 url "http://www.uvm.edu/~abh/stat295/datasets/trees2002.dat"; filename foo4 url "http://www.uvm.edu/~abh/stat295/datasets/trees2004.dat"; filename foo6 url "http://www.uvm.edu/~abh/stat295/datasets/trees2006.dat"; data trees02; infile foo2; input plot tree treatment $ dbh02; run; data trees04; infile foo4; input plot tree treatment $ dbh04; run; data trees06; infile foo6; input plot tree treatment $ dbh06; run; proc sort data=trees02; by plot tree; run; proc sort data=trees04; by plot tree; run; proc sort data=trees06; by plot tree; run; data trees020406; merge trees02 trees04 trees06; by plot tree; run; proc print data=trees020406; title "Tree diameters in 2002, 2004, and 2006"; run; data treesuni1; set trees020406; year = 2002; dbh = dbh02; output; year = 2004; dbh = dbh04; output; year = 2006; dbh = dbh06; output; drop dbh02 -- dbh06; run; proc print data=treesuni1; title "Rearranged in univariate form by long method"; run; data treesuni2; set trees020406; array d {3} dbh02 -- dbh06; do i = 1 TO 3; dbh = d{i}; year = 2000 + 2*i; output; end; drop dbh02 -- dbh06 i; run; proc print data=treesuni2; title "Rearranged in univariate form using ARRAY statement"; run; proc compare base=treesuni1 compare=treesuni2; run; proc transpose data=trees020406 out=treesuni3; by plot tree treatment; var dbh02 -- dbh06; RUN; data treesuni3; set treesuni3; year = 2000 + substr(_NAME_,4); rename col1 = dbh; drop _NAME_; run; proc print data = treesuni3; title "Rearranged in univariate form using PROC TRANSPOSE"; run; proc compare base=treesuni2 compare=treesuni3; run;