LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2011)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 23 Nov 2011 15:50:51 -0800
Reply-To:     David Marso <david.marso@gmail.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         David Marso <david.marso@gmail.com>
Subject:      Re: Improve maro efficiency
In-Reply-To:  <CACvW2fxuHXe9BnF_XB+BiJENtujghq-m5SKBXEKepp45KMavUA@mail.gmail.com>
Content-Type: text/plain; charset=us-ascii

"I'd like to question whether this is some limitation in the use of DEFINE (and !DO loops within DEFINE) ". Not that I am aware of! "or perhaps in the way I have coded the macro to achieve the desired result." More than likely! " If the latter (which would be my guess!), would there be a alternative way to code the macro to use less memory(?), loops(?) and simply be more efficient?" Probably so. Perhaps Post a sample invocation which hoses the process. Not going to stab at it in the dark.

J Sutar wrote > > I have written a macro which generates syntax to run VARSTOCASES command. > The purpose of the macro is so a user can easily paste in the variables in > the order as they appear in the data file and then the macro re-arranges > them in the appropriate format for use in VARSTOCASES syntax. See below > for > macro with an example. > > The macro works fine when the number of variables entered in the "vars" > parameter is relatively 'small'. I've not yet figured out the threshold > for > 'small'. But when there is a long list of variables (300+) then the macro > takes extremely long time to either kick in or even get started in the > first place. > > It either > > 1. Hangs on the previous command in the syntax > 2. Takes a very long time to start running but eventually does the job > 3. Hangs for eternity with the status bars displaying "Running > !VarsToCasesMacro nbVars ends with /...". I suspect it would eventually > get > to running the VARSTOCASES command but takes way too long to get there. > > One thing to note is that, if I manually generate the syntax manually and > run the VARSTOCASES command then it runs without any hindrance. So it > seems > to be the macros attempt to generate the syntax being problematic (with > all > the looping that's going on?)? > > I'd like to question whether this is some limitation in the use of DEFINE > (and !DO loops within DEFINE) or perhaps in the way I have coded the macro > to achieve the desired result. If the latter (which would be my guess!), > would there be a alternative way to code the macro to use less memory(?), > loops(?) and simply be more efficient? > > Many thanks in advance! > Jignesh > > > > define !VarsToCasesMacro (vars = !charend('/') > / nbVars = !charend('/') > / prefix = !charend('/') > / indexname = !charend('/') !default ('Index')) > set mprint on. > /* ------------------------------------------------------ */ > /* calculate total number of vars */ > /* ------------------------------------------------------ */ > !let !counter1=!blanks(0) > !do !i !in (!vars) > !let !counter1=!concat(!counter1,!blanks(1)) > !doend > !let !TotalnbVars=!len(!counter1) > /* ------------------------------------------------------ */ > /* modulus of !TotalnbVars / !nbVars, using > loops */ > /* ------------------------------------------------------ */ > /* if we don't have a division-by-zero error... */ > !if (!nbVars <> 0) !then > !let !answer = 0 > /* do division */ > !do !y = !TotalnbVars !to !nbVars !by -!nbVars > !doend > /* modulus = !y - !nbVars */ > !let !first = true > !do !x = !y !to 0 !by -!nbVars > !if (!first = true) !then > !let !first = false > !else > !let !answer = !x > !break > !ifend > !doend > !ifend > > !if (!answer <>0) !then /*do nothing*/ > !else > /* ------------------------------------------------------ */ > /* generate vartocases syntax */ > /* ------------------------------------------------------ */ > varstocases > !let !varsTail=!vars > !do !start=1 !to !nbVars > !let !varsHead=!head(!varsTail) > !let !varsTail=!tail(!varsTail) > !let !from=!null > !do !i = !start !to !TotalnbVars !by !nbVars > !let !counter2=!blanks(0) > !do !j !in (!vars) > !let !counter2=!concat(!counter2,!blanks(1)) > !let !varindex=!len(!counter2) > !if (!i=!varindex) !then > !let !from=!concat(!from," ",!j) > !ifend > !doend > !doend > !if (!prefix<>!null) !then !let > !varshead=!concat(!prefix,!start) !ifend > /make !varshead from !from > !doend > /index = !indexname. > !ifend > set mprint off. > !enddefine. > > !VarsToCasesMacro vars= A1 A2 A3 A4 A5 B1 B2 B3 B4 B5 C1 C2 C3 C4 C5 > /nbvars=5. > > Syntax generated by macro: > > varstocases /make A1 from A1 B1 C1 > /make A2 from A2 B2 C2 > /make A3 from A3 B3 C3 > /make A4 from A4 B4 C4 > /make A5 from A5 B5 C5 /index = Index. >

-- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Improve-maro-efficiency-tp5016698p5018812.html Sent from the SPSSX Discussion mailing list archive at Nabble.com.

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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


Back to: Top of message | Previous page | Main SPSSX-L page