* Say you need to run the file c:\\temp\\mysyntax.sps when a given variable does not exists. * The following syntax checks whether the given variable exists. * NOTE: Before running this syntax, you need to create the file c:\\temp\\mysyntax.sps. * It could contain a single line with a comment ' *This is the mysyntax.sps file'. * Posted to SPSSX-L list on 2001/04/24 by rlevesque@videotron.ca. SET MPRINT=yes. */////////////////////////////. DEFINE !exist (varname=!TOKENS(1)) SAVE OUTFILE='c:\\temp\\temp.sav'. N OF CASES 1. FLIP. IF (!QUOTE(!UPCASE(!varname))=CONCAT('',RTRIM(UPCASE(case_lbl)),'')) exist=1. COMPUTE dummy=1. AGGREGATE /OUTFILE=* /BREAK=dummy /exist = MAX(exist). DO IF ~MISSING(exist). WRITE OUTFILE='c:\\temp\\testvar.sps' /'* Nothing to do, variable exists.'. ELSE. WRITE OUTFILE='c:\\temp\\testvar.sps' /'* Variable does not exist, must include file.' /'INCLUDE FILE=''c:\\temp\\mysyntax.sps''.'. END IF. EXECUTE. GET FILE='c:\\temp\\temp.sav'. INCLUDE FILE='c:\\temp\\testvar.sps'. !ENDDEFINE. */////////////////////////////. GET FILE='c:\\program files\\spss\\employee data.sav'. * Next macro call will NOT include the file mysyntax.sps. !exist varname=educ. GET FILE='c:\\program files\\spss\\employee data.sav'. * Next macro call will INCLUDE the file mysyntax.sps. !exist varname=notexist.