|
|
Dear David,
I also just started learning some very basic Python and I'm already a fan! However, I found it hard to understand what you're trying to accomplish. You start with one .sav file, create 927 new .sav files and then add them up to one .sav file again. I probably misunderstand your exact situation but from what you posted I didn't see any necessity to do so. I guess that g4id1 to g4id9 can contain more than one value from (1-927), right? Because if not, a solution would be compute report_owner=0. do repeat a=1 to 927. if any(a,g4id1 to g4id9) report_owner=a. end repeat. execute. If g4id1 to g4id9 can contain more than one value from (1-927) then one record in the original file becomes (number of different values between 1-927 within g4id1 to g4id9) record in the new file with an obvious maximum of 9. This can be easily accomplished by an XSAVE command placed in a loop (with thanks to David Marso). See the code below. If this doesn't help, then please try to repost your situation with a more detailed explanation of what you wish to accomplish, OK? HTH, Ruben van den Berg Consultant Models & Methods TNS NIPO Email: [hidden email] Mobiel: +31 6 24641435 Telefoon: +31 20 522 5738 Internet: www.tns-nipo.com *Create testdata. set seed 1. dataset close all. data list free/id. begin data 1 2 3 4 5 end data. dataset name d1. do repeat a=g4id1 to g4id9. compute a=rnd(rv.uni(.5,10.5)). end repeat. execute. *Use xsave. loop #i=1 to 10. do if any(#i,g4id1 to g4id9). compute report_owner=#i. xsave outfile='c:\temp\final_file.sav'. end if. end loop. execute. delete variables report_owner. *Visually inspect the new file. get file='c:\temp\final_file.sav'. Date: Thu, 17 Jun 2010 08:50:28 -0700 From: [hidden email] Subject: Converting a Macro to a Python Program To: [hidden email]
New Windows 7: Find the right PC for you. Learn more. |
|
I am out of the office until June 23rd. If you need immediate assistance please contact 479-575-2905.
Thank you. ===================== 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 |
