|
Here are two macros-- the first one defines a path. The second calls a
set of files. Define !ftgd_dr () !QUOTE('D:\juL2007-') !enddefine. DEFINE !ftg_sp (). !DO !R = 1 !TO 5. GET FILE= !QUOTE(!CONCAT( !ftgd_dr,!R,".sav")) . DATASET NAME !CONCAT('ftgdata',!R) WINDOW=FRONT. !DOEND !ENDDEFINE. The !dtgd_dr token does not expand in the second macro (either for the GET FILE or the DATASET NAME) Thanks in advance for the help. --jim |
|
Hi
There are 2 possible solutions: 1st solution: GET FILE= !QUOTE(!CONCAT(!EVAL(!ftgd_dr),!R,".sav")) 2nd solution: DEFINE !ftg_sp (ftgd_dr=!TOKENS(1)) HTH -- Raynald Levesque www.spsstools.net On 8/29/07, Marks, Jim <[hidden email]> wrote: > > Here are two macros-- the first one defines a path. The second calls a > set of files. > > Define !ftgd_dr () > !QUOTE('D:\juL2007-') > !enddefine. > > > DEFINE !ftg_sp (). > > !DO !R = 1 !TO 5. > > GET FILE= !QUOTE(!CONCAT( > !ftgd_dr,!R,".sav")) > . > DATASET NAME !CONCAT('ftgdata',!R) WINDOW=FRONT. > !DOEND > !ENDDEFINE. > > The !dtgd_dr token does not expand in the second macro (either for the > GET FILE or the DATASET NAME) > > Thanks in advance for the help. > > --jim > |
|
In reply to this post by Marks, Jim
Hi Jim:
Perhaps you could pass the path as an argument of the MACRO. This code is untested but, something like this might work OK: DEFINE !ftg_sp(!POS !TOKENS(1)). !DO !R =1 !TO 5. . !LET !filename=!QUOTE(!CONCAT(!1,!QUOTE(!R),'.sav'). . !LET !datasetname=!CONCAT('ftgdata',!R). . GET FILE=!filename. . DATASET NAME !datasetname WINDOW=FRONT. !DOEND. !ENDDEFINE. !ftg_sp 'D:\juL2007-'. Also, have you taken a look at the syntax guide information concerning FILE HANDLE? HTH, Marta > Here are two macros-- the first one defines a path. The second calls a > set of files. > > Define !ftgd_dr () > !QUOTE('D:\juL2007-') > !enddefine. > > > DEFINE !ftg_sp (). > > !DO !R = 1 !TO 5. > > GET FILE= !QUOTE(!CONCAT( > !ftgd_dr,!R,".sav")) > . > DATASET NAME !CONCAT('ftgdata',!R) WINDOW=FRONT. > !DOEND > !ENDDEFINE. > > The !dtgd_dr token does not expand in the second macro (either for the > GET FILE or the DATASET NAME) > > Thanks in advance for the help. > > --jim > > |
|
In reply to this post by Marks, Jim
Jim, you probably need to use !EVAL (macro name) in the code of the second macro.
From the manual: "!EVAL (str) = Scan the argument for macro calls. During macro definition, an argument to a function or an operand in an expression is not scanned for possible macro calls unless the !EVAL function is used. It returns a string that is the expansion of its argument. For example, if mac1 is a macro, then !EVAL(mac1) returns the expansion of mac1. If mac1 is not a macro, !EVAL(mac1) returns mac1." HTH Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marks, Jim Sent: Wednesday, August 29, 2007 4:32 PM To: [hidden email] Subject: Macro not expanding Here are two macros-- the first one defines a path. The second calls a set of files. Define !ftgd_dr () !QUOTE('D:\juL2007-') !enddefine. DEFINE !ftg_sp (). !DO !R = 1 !TO 5. GET FILE= !QUOTE(!CONCAT( !ftgd_dr,!R,".sav")) . DATASET NAME !CONCAT('ftgdata',!R) WINDOW=FRONT. !DOEND !ENDDEFINE. The !dtgd_dr token does not expand in the second macro (either for the GET FILE or the DATASET NAME) Thanks in advance for the help. --jim _____ Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem. This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission. -.- -- |
|
In reply to this post by Marta Garcia-Granero
Thanks to Jan, Marta, and Raynald for the replies.
I ended up using the !EVAL solution instead of !TOKENS ( I kept getting extra apostrophes in the !LET statement when I used !TOKEN). Here is the relevant line of code: GET FILE= !QUOTE(!CONCAT(!UNQUOTE(!EVAL(!ftgd_dr)),!R,".sav")) I needed to have single apostrophes in the external macro to get it to read correctly. Then I used EVAL and UNQUOTE to get the extra apostrophes removed. Not sure why, but it works. Marta: I haven't looked at the syntax for file handle commands since the late '80s - early 90's:-) --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta Garcia-Granero Sent: Wednesday, August 29, 2007 10:05 AM To: [hidden email] Subject: Re: Macro not expanding Hi Jim: Perhaps you could pass the path as an argument of the MACRO. This code is untested but, something like this might work OK: DEFINE !ftg_sp(!POS !TOKENS(1)). !DO !R =1 !TO 5. . !LET !filename=!QUOTE(!CONCAT(!1,!QUOTE(!R),'.sav'). . !LET !datasetname=!CONCAT('ftgdata',!R). . GET FILE=!filename. . DATASET NAME !datasetname WINDOW=FRONT. !DOEND. !ENDDEFINE. !ftg_sp 'D:\juL2007-'. Also, have you taken a look at the syntax guide information concerning FILE HANDLE? HTH, Marta > Here are two macros-- the first one defines a path. The second calls a > set of files. > > Define !ftgd_dr () > !QUOTE('D:\juL2007-') > !enddefine. > > > DEFINE !ftg_sp (). > > !DO !R = 1 !TO 5. > > GET FILE= !QUOTE(!CONCAT( > !ftgd_dr,!R,".sav")) > . > DATASET NAME !CONCAT('ftgdata',!R) WINDOW=FRONT. > !DOEND > !ENDDEFINE. > > The !dtgd_dr token does not expand in the second macro (either for the > GET FILE or the DATASET NAME) > > Thanks in advance for the help. > > --jim > > |
| Free forum by Nabble | Edit this page |
