Date: Thu, 2 Dec 2004 12:35:27 +0200
Reply-To: Martins.Liberts@csb.gov.lv
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Martins Liberts <Martins.Liberts@csb.gov.lv>
Subject: Re: "/" after the macro calls
Content-Type: text/plain; charset="us-ascii"
I just found out that the trick with slash (/) doesn't work in AGGREGATE.
Example1. It is OK.
agg out=!dataq+"\Work\out_"+!varq+"_"+!subgrq+".sav"
/break !subgr /outl=sum(!var_nr)
/!temp /outl2=sum(!var_nr).
Example2. Should work, but it doesn't.
agg out=!dataq+"\Work\out_"+!varq+"_"+!subgrq+".sav"
/break !subgr/
/outl=sum(!var_nr)
/!temp/
/outl2=sum(!var_nr).
2396 M>
agg out=!dataq+"\Work\out_"+!varq+"_"+!subgrq+".sav"
2397 M> agg out='C:\My Documents\Darbs\IntraStat\data_200407\Reize2\Data'
2398 M> +"\Work\out_"+'EXP'
2399 M> +"_"+'NOD'
/break !subgr/
2400 M> +".sav"
2401 M> /break NOD
2402 M> /
/outl=sum(!var_nr)
2403 M> /outl=sum(EXP_67
2404 M> )
/!temp/
2405 M> /N=N
2406 M> /
/outl2=sum(!var_nr).
2407 M> /outl2=sum(EXP_67
2408 M> ).
>Error # 10917 in column 3. Text: /
>SPSS expected the definition of a new variable on the AGGREGATE command
but
>did not find a new variable name.
>This command not executed.
>Error # 10917 in column 3. Text: /
>SPSS expected the definition of a new variable on the AGGREGATE command
but
>did not find a new variable name.
It is strange because in MATCH FILES command the line with "/" doesn't
couse an error.
2169 M>
match files
2170 M> match files
/file=!pathq+"\data64\Ready\"+!varq+"_"+!subgrq+".sav"
2171 M> /file='C:\My Documents\Darbs\IntraStat'
2172 M> +"\data64\Ready\"+'EXP'
2173 M> +"_"+'NOD'
/in prev
2174 M> +".sav"
2175 M> /in prev
/file=*
2176 M> /file=*
/rename !var=!var_nr/
2177 M> /rename EXP
2178 M> =EXP_67
2179 M> /
/by nmk !subgr/
2180 M> /by nmk NOD
2181 M> /
/keep nmk !subgr !varl !var_nr.
2182 M> /keep nmk NOD
2183 M> EXP_59 EXP_60 EXP_61 EXP_62 EXP_63 EXP_64
2184 M> EXP_67
2185 M> .
Probably it is because in AGGREGATE after the /break subcommand there
could be only subcommands for definitions of a new variables. In MATCH
FILES after /rename and /by subcommands (as in the example) there could be
different subcommands.
--
Martins Liberts
Central Statistical Bureau of Latvia
address: Lacplesa iela 1, Riga, LV-1301, Latvia
phone: 371-7366877
email: Martins.Liberts@csb.gov.lv
Richard Ristow <wrristow@mindspring.com>
Sent by: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
01.12.2004 19:51
Please respond to Richard Ristow
To: SPSSX-L@LISTSERV.UGA.EDU
cc:
Subject: Re: Macros and importing data ["/" after the macro calls]
At 11:44 AM 12/1/2004, David Hutton asked:
>Richard:
>You wrote:
>_______________________________________________________________________
>>As for the macros inserting newlines, yes, they do. I don't know why
>>it
>>was done that way, but it's one of the things I like least about SPSS
>>macros. It means that the following works:
>>
>>MATCH FILES
>> /FILE= !D_SAVE(HV_Base)/
>> /FILE= !D_SAVE(IntvSmry)/
>> /BY FAMKEY HV_DT VISIT# ACC_DB.
>>
>>and the following doesn't:
>>
>>MATCH FILES
>> /FILE= !D_SAVE(HV_Base)
>> /FILE= !D_SAVE(IntvSmry)
>> /BY FAMKEY HV_DT VISIT# ACC_DB.
>>
>>The only difference is leaving out "/" after the macro calls.
>_______________________________________________________________________
>
>Would you mind expanding on this, please?
>Does !D_SAVE(HV_Base) expand to something like
>'C:\temp\myfile.sav' ?
Yes, exactly.
>Can I assume that _any_ multi-line command would be affected?
And again, yes. If there's interpreted text following the macro call,
on the same line, that text is interpreted as if it were on a
continuation of the command line (meaning, it's handled normally). If
there's no interpreted text (a comment is NOT good enough), a blank
line is effectively inserted, and later lines meant as part of the
command are considered "unrecognized keywords".
>What if the command (e.g. MATCH FILES) is itself within a macro?
If there's a macro VARIABLE as part of a command within a macro, no
extra new-line is inserted. If a macro INVOCATION is part of a command
within a macro, I'm not positive, but I'd count, myself, on its
inserting the newline.
I have no idea why macro expansions do insert newlines. I learned it
the hard way, myself. I've never found it described in documentation,
or in notes from SPSS people. I don't know whether it's bug or feature.
I've assumed, feature; that is, they meant it that way, for some
reason. But, if so, I don't know the reason.
-Best regards,
Richard