* Define a macro which will give us the names of the string variables as well as the list of numeric variables contained in the list given to the macro; after running the macro, the macros !num yields the list of numeric variables and the macro !str yields the list of numeric variables * Posted to SPSSX-L list by rlevesque@videotron.ca on 2001/07/18. GET FILE='c:\\Program Files\\SPSS\\employee data.sav'. *//////////////////////. DEFINE !VarType (!POS=!CMDEND) SAVE OUTFILE='c:\\temp\\temp.sav'. MATCH FILES FILE=* /KEEP=!1. N OF CASES 1. SET ERRORS=no. DO REPEAT v=!1. COMPUTE v=1. END REPEAT. SET ERRORS=yes. FLIP. IF MISSING(var001) var001=0. SORT CASES BY var001. MATCH FILES FILE=* /BY var001 /LAST=last. DO IF $CASENUM=1. WRITE OUTFILE="c:\\temp\\string vars.sps" /"DEFINE !str()". WRITE OUTFILE="c:\\temp\\num vars.sps" /"DEFINE !num()". END IF. DO IF var001 = 0. WRITE OUTFILE="c:\\temp\\string vars.sps" /" " case_lbl. ELSE. WRITE OUTFILE="c:\\temp\\num vars.sps" /" " case_lbl. END IF. DO IF last and var001=0. WRITE OUTFILE="c:\\temp\\string vars.sps" /"!ENDDEFINE.". ELSE IF last and var001=1. WRITE OUTFILE="c:\\temp\\num vars.sps" /"!ENDDEFINE.". END IF. EXECUTE. INCLUDE FILE="c:\\temp\\string vars.sps". INCLUDE FILE="c:\\temp\\num vars.sps". GET FILE='c:\\temp\\temp.sav'. !ENDDEFINE. *//////////////////////. ** Example of use of the macro. !VarType id TO jobcat. * List string variables. LIST !str. * List numeric variables. LIST !num. ***** Note: If you use the macro !str and !num within a macro, use the expressions such as !EVAL(!str) and !EVAL(!num) instead of just the macro names.