Syntax for "insert cases"?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax for "insert cases"?

Villegas Emilio
Hello!

Does anybody know how to write a syntax for inserting new cases in an
existing open file?

There is a botton in SPSS that has this function to insert cases but I
would like to have a syntax instead.



Thanks

 

Emilio Villegas
Reply | Threaded
Open this post in threaded view
|

AW: Syntax for "insert cases"?

la volta statistics
Hi Emilio

I think it there is no syntax equivalent for the GUI 'Insert Case'.
However, you could use the Add file command and add one (or several cases)
created with a DATA LIST command.
If you have python installed and SPSS 15, you could use a Python code for
inserting one ore several cases.
Look at the syntax examples below (you will need SPSS 14 or later for having
two datasets open simultaneously).

Hope this helps, Christian



DATA LIST FREE /ID (F) Name(A10).
BEGIN DATA
1 Mueller
2 Huber
3 Kunz
END DATA.

DATASET NAME first.

DATA LIST FREE /ID (F) .
BEGIN DATA
4
5
END DATA.

DATASET NAME Second.
ADD FILES /FILE=*
 /FILE='first'.
EXECUTE.

* if you have python installed and SPSS 15 you could also do it this way:.
New File.
DATASET CLOSE all.

DATA LIST FREE /ID (F) Name(A10).
BEGIN DATA
1 Mueller
2 Huber
3 Kunz
END DATA.

BEGIN PROGRAM.
import spss
cur=spss.Cursor(accessType='a')
cur.SetValueNumeric('ID',4)
cur.SetValueChar('Name','Smith')
cur.CommitCase()
cur.SetValueNumeric('ID',5)
cur.SetValueChar('Name','Bissell')
cur.CommitCase()
cur.EndChanges()
cur.close()
END PROGRAM.



*******************************.
la volta statistics
Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
Ch-8006 Zurich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email: mailto:[hidden email]
internet: http://www.lavolta.ch/


-----Ursprungliche Nachricht-----
Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von
Villegas Emilio
Gesendet: Donnerstag, 8. Marz 2007 09:47
An: [hidden email]
Betreff: Syntax for "insert cases"?


Hello!

Does anybody know how to write a syntax for inserting new cases in an
existing open file?

There is a botton in SPSS that has this function to insert cases but I
would like to have a syntax instead.



Thanks



Emilio Villegas