|
Dear spss geeks
I'm looking for a possibility to tell spss via programcode to generate a new Record in a Dataset (like "Insert cases"-command from the Edit-menu, but automated). I'm working with version 16. Thanks for any suggestions. Luis Luis Manuel Falcato, lic. phil. Leiter Evaluation + Forschung ARUD Zürich Sihlhallenstrasse 30 CH-8026 Zürich Tel: ++41 (0)44 248 37 32 Fax: ++41 (0)44 248 37 39 www.arud-zh.ch www.gain-zh.ch ===================== 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 Luis
One easy way would be to add a new case created with a DATA LIST ... command and then add the file. The code below creates a new variable. If you want to have the new case in an existing variable change the code from: DATA LIST FREE /newvar. -> to DATA LIST FREE /oldvar. Hope this helps, Christian New File. DATASET CLOSE ALL. DATA LIST FREE /oldvar . BEGIN DATA 1 2 3 4 5 6 7 8 9 END DATA. DATASET NAME oldfile WINDOW=FRONT. DATA LIST FREE /newvar . BEGIN DATA 10 END DATA. DATASET NAME newfile. DATASET ACTIVATE oldfile. ADD FILES /FILE=* /FILE='newfile'. EXECUTE. DATASET CLOSE newfile. ********************************** la volta statistics Christian Schmidhauser, Dr.phil.II Weinbergstrasse 108 CH-8006 Zürich Tel: +41 (043) 233 98 01 Fax: +41 (043) 233 98 02 email: mailto:[hidden email] Web: www.lavolta.ch -----Ursprüngliche Nachricht----- Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Falcato Luis Gesendet: Freitag, 16. Januar 2009 11:48 An: [hidden email] Betreff: Question: How to generate a new case with syntax / script Dear spss geeks I'm looking for a possibility to tell spss via programcode to generate a new Record in a Dataset (like "Insert cases"-command from the Edit-menu, but automated). I'm working with version 16. Thanks for any suggestions. Luis Luis Manuel Falcato, lic. phil. Leiter Evaluation + Forschung ARUD Zürich Sihlhallenstrasse 30 CH-8026 Zürich Tel: ++41 (0)44 248 37 32 Fax: ++41 (0)44 248 37 39 www.arud-zh.ch www.gain-zh.ch ===================== 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 Falcato Luis
With Python you can use the Cursor class to add cases to the dataset,
specifically "spss.Cursor(accessType='a')". Here's an example from Ch 15 in the SPSS Programming and Data Management book: *python_append_cases.sps. DATA LIST FREE /case (F) value (A1). BEGIN DATA 1 a END DATA. BEGIN PROGRAM. import spss cur=spss.Cursor(accessType='a') cur.SetValueNumeric('case',2) cur.SetValueChar('value','b') cur.CommitCase() cur.SetValueNumeric('case',3) cur.SetValueChar('value','c') cur.CommitCase() cur.EndChanges() cur.close() END PROGRAM. Falcato Luis wrote: > Dear spss geeks > > I'm looking for a possibility to tell spss via programcode to generate a new Record in a Dataset (like "Insert cases"-command from the Edit-menu, but automated). I'm working with version 16. Thanks for any suggestions. > > Luis > > > > Luis Manuel Falcato, lic. phil. > Leiter Evaluation + Forschung > ARUD Zürich > Sihlhallenstrasse 30 > CH-8026 Zürich > > Tel: ++41 (0)44 248 37 32 > Fax: ++41 (0)44 248 37 39 > > www.arud-zh.ch > www.gain-zh.ch > > ===================== > 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 > > -- Daniel Robertson Senior Research and Planning Associate Institutional Research and Planning Cornell University / irp.cornell.edu ===================== 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 Falcato Luis
At 05:48 AM 1/16/2009, Falcato Luis wrote:
>I'm looking for a possibility to tell spss via programcode to >generate a new Record in a Dataset (like "Insert cases"-command from >the Edit-menu, but automated). I'm working with version 16. Thanks >for any suggestions. In native SPSS code, look at XSAVE OUTFILE=. It will actually write to a .SAV file on disk (syntax essentially the same as SAVE OUTFILE=); you'll then use ADD FILES to merge old and new records. There are actually various ways; which is best depends on your particular needs. ===================== 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 |
