*(Q) In the example below, everything works fine as long as values of 1, 2, and 3 exist (1=undergraduate students, 2=post-baccalaureate students, 3=masters students). But, when the macro runs across an undergraduate program with no master's students, an SPSS warning is given and the macro is terminated. *(A) posted by Raynald Levesque to SPSS newsgroup on 2002/03/29. **************. * Illustration of the problem. **************. SET MPRINT=no. DEFINE JMAC1 (V1=!TOKENS(1) / V2=!TOKENS(1)) /* Since jobcats is either 1,2 or 3, the following loop */ /* result in an error */ !DO !V3 = 1 !TO 4 get file = 'C:\Program Files\SPSS\employee data.sav'. select if (gender = !V1 and jobcat = !V3). FREQ VAR=jobcat. LIST. !DOEND. !ENDDEFINE. SET MPRINT=yes. INCLUDE 'c:\temp\CB1_DEPT.MAC'. EXECUTE. **************. *One possible solution. **************. SET MPRINT=no. *///////////////. DEFINE JMAC1 (V1=!TOKENS(1) / V2=!TOKENS(1)) * Since jobcats is either 1,2 or 3, the following loop would. * normally result in an error. !DO !V3 = 1 !TO 4 get file = 'C:\Program Files\SPSS\employee data.sav'. * add the case with all empty values. ADD FILES FILE=* /FILE='c:\temp\empty.sav'. * Note that 'or MISSING(id)' has been added in next line. SELECT IF (gender = !V1 and jobcat = !V3) OR MISSING(id). FREQ VAR=id. LIST. !DOEND. !ENDDEFINE. *///////////////. * Do some preparatory work then call macro. * Create a one case data file where all cases are missing. get file = 'C:\Program Files\SPSS\employee data.sav'. N OF CASES 1. SET ERRORS=none. DO REPEAT var=ALL. COMPUTE var=$SYSMIS. COMPUTE var="". END REPEAT. SET ERRORS=listing. SAVE OUTFILE='c:\temp\empty.sav'. SET MPRINT=yes. INCLUDE 'c:\temp\CB1_DEPT.MAC'.