|
Hi all,
I am using SPSS 12 and hav found wierd problem with macro DO loop and INCLUDE. I try to give an example. I have a syntax file "D:\temp\comp.sps" which contains some dummy syntax: ***. comp a=1. comp a=1. comp a=1. comp a=1. comp a=1. ***. Just 5 lines of code. Then I am defining and running such macro: ***. define !labels_tmp(list=!cmdend) !do !var !in (!list) include "D:\temp\comp.sps". !doend !end. set mprint=on. set printback=on. !labels_tmp list=a. set printback=off. set mprint=off. ***. And in result I get something realy wired in output: ***. >Warning # 6804 in column 3. Text: !labels_tmp >The macro name specified on the DEFINE command duplicates the name of a >previously defined macro. This instance will take precedence. !labels_tmp list=a. 1738 0 M> 1739 0 M> . 1740 0 M> include 'D:\temp\comp.sps'. 1740 0 comp a=1. 1740 0 M> comp a=1comp a=1 1741 0 comp a=1. 1741 0 M> >Error # 4381 on line 361740 in column 9. Text: comp >The expression ends unexpectedly. >This command not executed. >Note # 214 on line 361740. Command name: comp >Due to an error, INCLUDE file processing has been terminated and the >working file has been lost. You may either redefine your data or leave >SPSS. >Note # 236 >All outstanding macros have been terminated, all include processing has >been terminated, and all outstanding PRESERVE commands have been undone. set printback=off. 1743 0 M> set printback=off. ***. Look to the line 1740 (third one). How does "comp a=1comp a=1" is generated? Offcourse it makes an error. The problem is some how related to !DO loop in macro. Running it without !DO loop it works perfect: ***. define !labels_tmp(list=!cmdend) include "D:\temp\comp.sps". !end. set mprint=on. set printback=on. !labels_tmp. set printback=off. set mprint=off. ***. !labels_tmp. 1752 0 M> include 'D:\temp\comp.sps' 1753 0 M> . 1753 0 M> comp a=1 1754 0 comp a=1. 1754 0 M> 1755 0 M> comp a=1 1756 0 comp a=1. 1756 0 M> 1757 0 M> comp a=1 1758 0 comp a=1. 1758 0 M> 1759 0 M> comp a=1 1760 0 comp a=1. 1760 0 M> 1761 0 M> comp a=1 1762 0 comp a=1. 1762 0 M> 1763 0 1763 0 M> 1764 0 M> * End of INCLUDE nesting level 01 1765 0 * End of INCLUDE nesting level 01. 1765 0 M> set printback=off. 1766 0 M> set printback=off. ***. Can somebody give an explanation to that? Thanks! ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
