I need some input on how to set up loops and vectors correctly. In Raynald Levesque's "Programming and Data Management..." I found an example which I altered slightly:
NEW FILE. INPUT PROGRAM. VECTOR var(100,F2). LOOP #I=1 TO 100. LOOP #J=1 TO 100. COMPUTE var(#J)=RV.BINOM(25,0.2). END LOOP. END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. This works fine with a quadratic combination of 100 variables with 100 cases each. But what if I want to a setup with for example 50 variables with 500 cases each? I do hope to come to grips with loops and vectors sometime.... Robert ===================== 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
Robert Lundqvist
|
Robert,
Tweaked the syntax that you posted. Note where the 50 and the 500 are. INPUT PROGRAM. VECTOR var(50,F2). LOOP #I=1 TO 500. LOOP #J=1 TO 50. COMPUTE var(#J)=RV.BINOM(25,0.2). END LOOP. END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. Tony Babinec -----Original Message----- From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Robert Lundqvist Sent: Wednesday, May 29, 2019 4:16 AM To: [hidden email] Subject: LOOP question I need some input on how to set up loops and vectors correctly. In Raynald Levesque's "Programming and Data Management..." I found an example which I altered slightly: NEW FILE. INPUT PROGRAM. VECTOR var(100,F2). LOOP #I=1 TO 100. LOOP #J=1 TO 100. COMPUTE var(#J)=RV.BINOM(25,0.2). END LOOP. END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. This works fine with a quadratic combination of 100 variables with 100 cases each. But what if I want to a setup with for example 50 variables with 500 cases each? I do hope to come to grips with loops and vectors sometime... Robert ===================== 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 ===================== 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 Robert L
NEW FILE. INPUT PROGRAM. VECTOR var(50,F2). LOOP #I=1 TO 500. LOOP #J=1 TO 50. COMPUTE var(#J)=RV.BINOM(25,0.2). END LOOP. END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. Mario Giesel Munich, Germany
Am Mittwoch, 29. Mai 2019, 11:15:44 MESZ hat Robert Lundqvist <[hidden email]> Folgendes geschrieben:
I need some input on how to set up loops and vectors correctly. In Raynald Levesque's "Programming and Data Management..." I found an example which I altered slightly: NEW FILE. INPUT PROGRAM. VECTOR var(100,F2). LOOP #I=1 TO 100. LOOP #J=1 TO 100. COMPUTE var(#J)=RV.BINOM(25,0.2). END LOOP. END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. This works fine with a quadratic combination of 100 variables with 100 cases each. But what if I want to a setup with for example 50 variables with 500 cases each? I do hope to come to grips with loops and vectors sometime.... Robert ===================== 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 |
Administrator
|
I tend towards the following approach.
MATRIX. SAVE UNIFORM(500,50)/OUTFILE */VARIABLES x001 TO x050. END MATRIX. DO REPEAT x=x001 TO x050. COMPUTE x=RV.BINOM(25,0.2). END REPEAT. Make it more general with a MACRO. DEFINE !BuildData (N=!CHAREND ("/")/P=!CHAREND ("/") /Vars !CHAREND ("/")/Func !CMDEND) MATRIX. SAVE UNIFORM(!N,!P)/OUTFILE =*/VARIABLES =!Vars. END MATRIX. DO REPEAT x=!Vars. COMPUTE x=!Func. END REPEAT. !ENDDEFINE. /*Usage:*/. !BuildData N=500/P=50/Vars =x001 TO x050/Func =RV.BINOM(25,0.2). Mario Giesel-2 wrote > NEW FILE. > INPUT PROGRAM. > VECTOR var(50,F2). > LOOP #I=1 TO 500. > LOOP #J=1 TO 50. > COMPUTE var(#J)=RV.BINOM(25,0.2). > END LOOP. > END CASE. > END LOOP. > END FILE. > END INPUT PROGRAM. > EXECUTE. > > > > Mario GieselMunich, Germany > > Am Mittwoch, 29. Mai 2019, 11:15:44 MESZ hat Robert Lundqvist < > robert.lundqvist@ > > Folgendes geschrieben: > > I need some input on how to set up loops and vectors correctly. In > Raynald Levesque's "Programming and Data Management..." I found an example > which I altered slightly: > > NEW FILE. > INPUT PROGRAM. > VECTOR var(100,F2). > LOOP #I=1 TO 100. > LOOP #J=1 TO 100. > COMPUTE var(#J)=RV.BINOM(25,0.2). > END LOOP. > END CASE. > END LOOP. > END FILE. > END INPUT PROGRAM. > > EXECUTE. > > This works fine with a quadratic combination of 100 variables with 100 > cases each. But what if I want to a setup with for example 50 variables > with 500 cases each? I do hope to come to grips with loops and vectors > sometime.... > > Robert > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== 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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
David, generating data or a dataset ingot via MATRIX is fine. But
don't forget MATRIX depends on RAM memory. What if one needs to
generate millions by tens thousands size dataset and they don't have
much RAM on their PC?
===================== 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 |
Administrator
|
1. Build it out incrementally.
SAVE within an outer loop. 2. Install more memory or use a beefier box? Kirill Orlov wrote > David, generating data or a dataset ingot via MATRIX is fine. But don't > forget MATRIX depends on RAM memory. What if one needs to generate > millions by tens thousands size dataset and they don't have much RAM on > their PC? > > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== 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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by spss.giesel@yahoo.de
If you want to avoid the intricacies of input programs and MATRIX, you can install this custom dialog box. It is a zip file. Installation instructions are in the file. Once installed, it will appear in the menus as File > New > Data with cases. This dialog generates a random dataset with an arbitrary number of variables and cases according to any of a large number of distributions and provides for correlations with various patterns. The distributions are generated by the standard random number generators in Statistics plus code for the triangular distribution, which is not available in the Statistics generators. To prove that this is technology neutral, it uses input programs, MATRIX, and Python programmability :-) On Wed, May 29, 2019 at 8:23 AM Mario Giesel <[hidden email]> wrote:
|
Administrator
|
In reply to this post by David Marso
Example of 1.
1,000,000 Cases, 5,000 Variables. PRESERVE. SET MXLOOPS=100. MATRIX. LOOP x=1 TO 100. SAVE UNIFORM(10000,5000)/OUTFILE */VARIABLES x0001 TO x5000. PRINT x. END LOOP. END MATRIX. RESTORE. DESCRIPTIVES x0001 x5000. David Marso wrote > 1. Build it out incrementally. > SAVE within an outer loop. > > 2. Install more memory or use a beefier box? > > > Kirill Orlov wrote >> David, generating data or a dataset ingot via MATRIX is fine. But don't >> forget MATRIX depends on RAM memory. What if one needs to generate >> millions by tens thousands size dataset and they don't have much RAM on >> their PC? >> >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to > >> LISTSERV@.UGA > >> (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 > > > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > --- > "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos > ne forte conculcent eas pedibus suis." > Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in > abyssum?" > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== 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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
One other element of a multi loop set up like is being discussed is that I've noticed that a leave command needs to be used to carry the current outer loop value down across the inner loop values. I didn't see that element in the replies.
Gene Maguin -----Original Message----- From: SPSSX(r) Discussion <[hidden email]> On Behalf Of David Marso Sent: Wednesday, May 29, 2019 2:31 PM To: [hidden email] Subject: Re: LOOP question Example of 1. 1,000,000 Cases, 5,000 Variables. PRESERVE. SET MXLOOPS=100. MATRIX. LOOP x=1 TO 100. SAVE UNIFORM(10000,5000)/OUTFILE */VARIABLES x0001 TO x5000. PRINT x. END LOOP. END MATRIX. RESTORE. DESCRIPTIVES x0001 x5000. David Marso wrote > 1. Build it out incrementally. > SAVE within an outer loop. > > 2. Install more memory or use a beefier box? > > > Kirill Orlov wrote >> David, generating data or a dataset ingot via MATRIX is fine. But >> don't forget MATRIX depends on RAM memory. What if one needs to >> generate millions by tens thousands size dataset and they don't have >> much RAM on their PC? >> >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to > >> LISTSERV@.UGA > >> (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 > > > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > --- > "Nolite dare sanctum canibus neque mittatis margaritas vestras ante > porcos ne forte conculcent eas pedibus suis." > Cum es damnatorum possederunt porcos iens ut salire off sanguinum > cliff in abyssum?" > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== 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 ===================== 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 |
Administrator
|
Not required here.
In OP the inner loop is moving horizontally. -- Maguin, Eugene wrote > One other element of a multi loop set up like is being discussed is that > I've noticed that a leave command needs to be used to carry the current > outer loop value down across the inner loop values. I didn't see that > element in the replies. > Gene Maguin > > > -----Original Message----- > From: SPSSX(r) Discussion < > SPSSX-L@.UGA > > On Behalf Of David Marso > Sent: Wednesday, May 29, 2019 2:31 PM > To: > SPSSX-L@.UGA > Subject: Re: LOOP question > > Example of 1. > 1,000,000 Cases, 5,000 Variables. > > PRESERVE. > SET MXLOOPS=100. > MATRIX. > LOOP x=1 TO 100. > SAVE UNIFORM(10000,5000)/OUTFILE */VARIABLES x0001 TO x5000. > PRINT x. > END LOOP. > END MATRIX. > RESTORE. > DESCRIPTIVES x0001 x5000. > > > David Marso wrote >> 1. Build it out incrementally. >> SAVE within an outer loop. >> >> 2. Install more memory or use a beefier box? >> >> >> Kirill Orlov wrote >>> David, generating data or a dataset ingot via MATRIX is fine. But >>> don't forget MATRIX depends on RAM memory. What if one needs to >>> generate millions by tens thousands size dataset and they don't have >>> much RAM on their PC? >>> >>> >>> ===================== >>> To manage your subscription to SPSSX-L, send a message to >> >>> LISTSERV@.UGA >> >>> (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 >> >> >> >> >> >> ----- >> Please reply to the list and not to my personal email. >> Those desiring my consulting or training services please feel free to >> email me. >> --- >> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante >> porcos ne forte conculcent eas pedibus suis." >> Cum es damnatorum possederunt porcos iens ut salire off sanguinum >> cliff in abyssum?" >> -- >> Sent from: http://spssx-discussion.1045642.n5.nabble.com/ >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to > >> LISTSERV@.UGA > >> (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 > > > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > --- > "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos > ne forte conculcent eas pedibus suis." > Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in > abyssum?" > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== 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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Robert L
Thanks for all your replies and suggestions. The thing I had missed was that the inner loop generates the variables, not
the cases as I had imagined. And correspondingly, the outer loops generates the cases. It seems almost natural now, but it wasn’t that clear before. Thanks again! Robert Från: SPSSX(r) Discussion [mailto:[hidden email]]
För Mario Giesel NEW FILE. Mario Giesel Munich, Germany
Robert Lundqvist
|
Free forum by Nabble | Edit this page |