* Some commands do not accept references such as var1 TO xyz5. * This macro produces a list of all variables between 2 given variables. * The macro is useful when there are hundreds of variables. * Because of a 'feature' of the macro parser, it is sometimes necessary to enclose the variable names in quotes. This is done in the macro qlist1 (see below). * Raynald Levesque rlevesque@videotron.ca 2001/03/24. *///////////////////////////////////////. DEFINE !DefList (var1=!TOKENS(1) /var2=!TOKENS(1) /fname=!CMDEND) GET FILE=!fname. COMPUTE dummy=1. N OF CASES 1. MATCH FILES FILE=* /BY dummy /KEEP=!var1 TO !var2. FLIP. COMPUTE dummy=1. MATCH FILES FILE=* /BY dummy /FIRST=first /LAST=last. DO IF first. WRITE OUTFILE='c:\\temp\\list1.sps' / 'DEFINE !list1()' case_lbl. WRITE OUTFILE='c:\\temp\\qlist1.sps' / 'DEFINE !qlist1()"' case_lbl'"'. ELSE if not last. WRITE OUTFILE='c:\\temp\\list1.sps' / " "case_lbl. WRITE OUTFILE='c:\\temp\\qlist1.sps' / " '"case_lbl"'". ELSE. WRITE OUTFILE='c:\\temp\\list1.sps' /" "case_lbl ' !ENDDEFINE'. WRITE OUTFILE='c:\\temp\\qlist1.sps' /" '"case_lbl"'" ' !ENDDEFINE'. END IF. EXECUTE. GET FILE=!fname. INCLUDE FILE='c:\\temp\\list1.sps'. * qlist1 = list1 with quoted variable names. INCLUDE FILE='c:\\temp\\qlist1.sps'. !ENDDEFINE. *///////////////////////////////////////. * I assume the 600 variables are consecutives, that is, there are no string variables between the first and 600th numeric variables. * Here I use only 5 variables to illustrate the procedure. * Assume we want to round the values to the nearest integer and change the format to F8.0. DATA LIST LIST /g x345 v3 b k. BEGIN DATA. 1.21 2.49 3.01 5.51 41.98 2.33 5.67 1.75 4.22 6.02 END DATA. SAVE OUTFILE='c:\\temp\\mydata.sav'. EXECUTE. SET MPRINT=yes. * The following code does the job. !DEfList var1=g var2=k fname="c:\\temp\\mydata.sav". DO REPEAT v=!list1. COMPUTE v=RND(v). FORMATS v(F8.0). END REPEAT PRINT. EXECUTE.