* Reorder vector names in data files. * This is useful when you have vectors say a1 TO a50, b1 TO b50, c1 TO c50. * and you want to reorder them as a1 b1 c1 a2 b2 c2 ... a50 b50 c50. * Raynald Levesque 2001/04/28. DATA LIST LIST /dummy. BEGIN DATA 1 END DATA. LIST. * Following vectors are "consecutive" (all a's, all b's then all c's). NUMERIC id x y a1 TO a50 z1 b1 TO b50 z2 c1 TO c50 k. * Say we want to Reorder vectors a b c "side by side" that is a1 b1 c1 a2 b2 c2 ... a50 b50 c50. SET MPRINT=yes. *//////////////////////. DEFINE !reorder (id=!TOKENS(1) /beg !TOKENS(1) / end !TOKENS(1) /vnames !CMDEND) MATCH FILES FILE=* /KEEP=!id !DO !i=!beg !TO !end !DO !var !IN (!vnames) !CONCAT(!var,!i," ") !DOEND !DOEND ALL. !ENDDEFINE. *//////////////////////. * Example of use of the macro. !reorder id=id beg=1 end=50 vnames=a b c. **********************. *** Explanations***. **********************. * The following format helps to understand the !DO - !END loops in the above match command, *!DO !i=!beg !TO !end * !DO !var !IN (!vnames) * !CONCAT(!var,!i," ") * !DOEND *!DOEND *ALL. * NOTES: * ALL means keep all other variables not previously named. * The macro loop is written in one line to reduce the number of lines in the syntax file being created. * Note that macro commands do NOT need a command terminator (a decimal point) at the end. In fact if periods had been inserted after !DO !i=!beg !TO !end for instance, the macro would no longer work! because this period would effectively "end" the MATCH FILES command.