|
The below syntax does not work. Reading the error messages, it is because
the !pathdata macro within !CONCAT does not expand in call up of the !RunSyn macro. How do I go about solving this? /***#######################################################################***/. DATASET CLOSE ALL. OUTPUT CLOSE ALL. NEW FILE. DEFINE !pathdata () 'C:\Program Files\spss\' !ENDDEFINE. DISPLAY MACRO. TITLE !Pathdata. DEFINE !RunSyn (file=!CMDEND). GET FILE = !CONCAT(!pathdata, !file,',sav'). FREQ ALL. !ENDDEFINE. SET MPRINT ON. !RunSyn file=emplyee data. !RunSyn file=coffee. SET MPRINT OFF. DISPLAY MACRO. /***#######################################################################***/. ===================== 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 |
|
Hi,
use !quote in addition to !concat: GET FILE = !quote(!CONCAT(!pathdata, !file,'.sav')). Or use something like this untested python equivalent. (replace the underscores with tabs, though): def runSyn (path, file): ___import spss ___spss.Submit(""" ___GET FILE = %(path)s/%(file).sav'). ___FREQ ALL. ___""" % locals()) runSyn (path='d:/temp', file='somefile') Cheers!! Albert-Jan ===================== 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 |
|
In reply to this post by Jignesh Sutar
J, Here's some code that works for me. I'm not simplifying it any more
because then I'll probably break something. /***#######################################################################***/. DEFINE !OMSpath () !unquote('Q:\instrsch\cak1\rpts.dir\oms_output\') !ENDDEFINE . DEFINE !OMSpathD () !concat(!eval(!OMSpath),'wHR001D_') !ENDDEFINE . DEFINE !FHandle (!pos !charend ('(') /!pos !charend (')') /!pos !charend (' ') ) . !do !filename !in (!2) file handle !filename /name=!quote(!unquote(!concat(!1,!filename,!3))) . !doend . !ENDDEFINE . !FHandle !OMSpathD (RankFreq RespSession le5percentResp ) . get file=RankFreq . /***#######################################################################***/. It isn't exactly the same but I suspect the !eval might be important to you as well. Catherine At 10/22/2008 09:49 AM, J Sutar wrote: >The below syntax does not work. Reading the error messages, it is because >the !pathdata macro within !CONCAT does not expand in call up of the !RunSyn >macro. > >How do I go about solving this? > >/***#######################################################################***/. >DATASET CLOSE ALL. >OUTPUT CLOSE ALL. >NEW FILE. >DEFINE !pathdata () 'C:\Program Files\spss\' !ENDDEFINE. >DISPLAY MACRO. >TITLE !Pathdata. > >DEFINE !RunSyn (file=!CMDEND). > >GET FILE = !CONCAT(!pathdata, !file,',sav'). > >FREQ ALL. > >!ENDDEFINE. > >SET MPRINT ON. >!RunSyn file=emplyee data. >!RunSyn file=coffee. >SET MPRINT OFF. >DISPLAY MACRO. > >/***#######################################################################***/. Catherine Kubitschek ([hidden email]) Sr. Programmer/Analyst 574/631-3550 Institutional Research 210 Flanner Hall University of Notre Dame Notre Dame, IN 46556-5611 ===================== 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 |
|
!EVAL solves the problem. Also, the inclusion of !QUOTE, !UNQUOTE solves
everything So this works fine: DEFINE !pathdata () 'C:\Program Files\spss\' !ENDDEFINE. DEFINE !RunSyn (file=!CMDEND). GET FILE = !QUOTE(!CONCAT(!UNQUOTE(!EVAL(!pathdata)), !file,'.sav')). FREQ ALL. !ENDDEFINE. SET MPRINT ON. !RunSyn file=employee data. !RunSyn file=coffee. SET MPRINT OFF. 2008/10/22 Catherine Kubitschek <[hidden email]> > J, Here's some code that works for me. I'm not simplifying it any more > because then I'll probably break something. > > > /***#######################################################################***/. > DEFINE !OMSpath () !unquote('Q:\instrsch\cak1\rpts.dir\oms_output\') > !ENDDEFINE . > DEFINE !OMSpathD () !concat(!eval(!OMSpath),'wHR001D_') !ENDDEFINE . > DEFINE !FHandle (!pos !charend ('(') /!pos !charend (')') > /!pos !charend (' ') ) . > !do !filename !in (!2) > file handle !filename /name=!quote(!unquote(!concat(!1,!filename,!3))) . > !doend . > !ENDDEFINE . > !FHandle !OMSpathD (RankFreq RespSession le5percentResp ) . > get file=RankFreq . > > /***#######################################################################***/. > > It isn't exactly the same but I suspect the !eval might be important to you > as well. > > Catherine > > > At 10/22/2008 09:49 AM, J Sutar wrote: > > The below syntax does not work. Reading the error messages, it is because > the !pathdata macro within !CONCAT does not expand in call up of the > !RunSyn > macro. > > How do I go about solving this? > > > /***#######################################################################***/. > DATASET CLOSE ALL. > OUTPUT CLOSE ALL. > NEW FILE. > DEFINE !pathdata () 'C:\Program Files\spss\' !ENDDEFINE. > DISPLAY MACRO. > TITLE !Pathdata. > > DEFINE !RunSyn (file=!CMDEND). > > GET FILE = !CONCAT(!pathdata, !file,',sav'). > > FREQ ALL. > > !ENDDEFINE. > > SET MPRINT ON. > !RunSyn file=emplyee data. > !RunSyn file=coffee. > SET MPRINT OFF. > DISPLAY MACRO. > > > /***#######################################################################***/. > > > Catherine Kubitschek ([hidden email]) > Sr. Programmer/Analyst 574/631-3550 > Institutional Research > 210 Flanner Hall > University of Notre Dame > Notre Dame, IN 46556-5611 > ===================== 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 |
