[R] how to read .sps (SPSS file extension)?

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Wed Nov 26 13:00:52 CET 2008


maybe the importers of the memisc-package will help you, but I never 
tried them, see

  help(importers,package="memisc")

At a first glance it seems, that you have to split your file manually, 
but maybe there is another way.
hth.

livio finos schrieb:
> sorry, you are completely right!
> sps is not the extension for portable file! sorry for the time I make 
> you spend.
> I try to make my problem more clear.
> I exporting a dataset from limesurvey (a free software for internet 
> survey). It works very fine and it allow to export in different format 
> such as csv and excel. this fine, but what I like from spss formats is 
> the variables labels.
> limesurvey declares to export in spss, but it export in sps format 
> which is not a format but a code actually. I realize it just now, 
> sorry. I attach an extract of the code here below.
> do you have any suggestion on how to manage that? I think it will be 
> great if we can improve the interconnettivity among free software.
> thanks again..
>   livio
>
> NEW FILE.
> FILE TYPE NESTED RECORD=1(A).
> - RECORD TYPE 'A'.
> - DATA LIST LIST / i0(A1) d1(N3) d2(DATETIME20.0) d3(A15) d4(N2) 
> d5(N1) d6(N1) d7(N1) d8(N1) d9(N1) d10(N1) d11(N1) d12(N1) d13(N1) 
> d14(N1) d15(N1) d16(N1) d17(N2) d18(N1) d19(N1) d20(N1) .
>
> - RECORD TYPE 'B'.
> - DATA LIST LIST / i1(A1) d21(N1) d22(N1) d23(N1) d24(N1) d25(N1) 
> d26(N1) d27(N1) d28(N1) d29(N1) d30(N1) d31(N1) d32(N1) d33(N1) 
> d34(N1) d35(N1) d36(N1) d37(N1) d38(A37) d39(N1) d40(N1) .
>
> - RECORD TYPE 'C'.
> - DATA LIST LIST / i2(A1) d41(N1) d42(N1) d43(N1) d44(N1) d45(N1) 
> d46(N1) d47(N1) d48(N1) d49(N1) d50(N1) d51(N1) d52(N1) d53(N1) 
> d54(N1) d55(N1) d56(N1) d57(N1) d58(N1) d59(N1) d60(N1) .
>
> - RECORD TYPE 'D'.
> - DATA LIST LIST / i3(A1) d61(N1) d62(N1) d63(N1) d64(N1) d65(N1) 
> d66(N1) d67(N1) d68(N1) d69(N1) d70(N1) d71(N1) d72(N1) d73(N1) 
> d74(N1) d75(N1) d76(N1) d77(N1) d78(N1) d79(N1) d80(N1) .
>
> - RECORD TYPE 'E'.
> - DATA LIST LIST / i4(A1) d81(N1) d82(N1) d83(N1) d84(N1) d85(N1) 
> d86(N1) d87(N1) d88(N1) d89(N1) d90(N1) d91(N1) d92(N1) d93(N1) 
> d94(N1) d95(N1) d96(N1) d97(N1) d98(N1) d99(N1) d100(N1) .
>
> - RECORD TYPE 'F'.
> - DATA LIST LIST / i5(A1) d101(N1) d102(N1) d103(N1) d104(N1) d105(N1) 
> d106(N1) d107(N1) d108(N1) d109(N1) .
> END FILE TYPE.
>
> BEGIN DATA
> A '8' '01-01-1980 00:00:00' 'it' '13' '1' '1' '' '1' '' '1' '1' '1' 
> '1' '1' '4' '0' '' '1' '' '1'
> B '' '1' '1' '1' '1' '0' '' '0' '' '2' '2' '1' '4' '2' '7' '3' '2' 
> '0''2' '3'
> C '3' '4' '4' '2' '2' '1' '4' '4' '2' '3' '1' '4' '1' '4' '1' '1' '4' 
> '3' '4' '3'
> D '1' '3' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '2' '2' '2' '2' '3' 
> '3' '3' '2'
> E '2' '3' '2' '2' '0''0''0''0''0''0''0''3' '4' '4' '2' '1' '5' '2' '5' 
> '4'
> F '1' '2' '2' '2' '2' '1' '2' '2' '5'
> A '9' '01-01-1980 00:00:00' 'it' '13' '2' '1' '' '1' '' '0' '' '1' '1' 
> '1' '3' '0' '' '1' '' '1'
> B '' '0' '' '1' '1' '0' '' '0' '' '2' '2' '1' '4' '3' '7' '3' '2' 
> '0''2' '4'
> C '3' '4' '4' '3' '3' '3' '4' '3' '2' '2' '1' '3' '1' '4' '1' '4' '4' 
> '4' '4' '3'
> D '1' '2' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '3' '1' '3' '3' '3' 
> '3' '3' '3'
> E '3' '3' '3' '2' '0''0''0''0''0''0''0''3' '4' '2' '2' '5' '3' '5' '2' 
> '5'
> F '1' '5' '5' '5' '5' '5' '5' '2' '5'
> A '10' '01-01-1980 00:00:00' 'it' '13' '1' '1' '' '1' '' '1' '2' '0' 
> '' '0' '' '0' '' '1' '' '1'
> B '' '1' '2' '0' '' '0' '' '0' '' '1' '2' '1' '4' '6' '7' '3' '2' 
> '0''3' '3'
> C '4' '4' '4' '4' '3' '4' '4' '3' '2' '2' '1' '4' '1' '4' '1' '3' '4' 
> '4' '4' '1'
> D '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '3' '3' '3' '3' '3' '3' 
> '3' '3' '3'
> E '3' '3' '3' '2' '0''0''0''0''0''0''0''5' '4' '5' '2' '5' '5' '5' '5' 
> '5'
> F '1' '5' '5' '5' '5' '5' '5' '1' '5'
> END DATA.
> EXECUTE.
>
> *Define Variable Properties.
> VARIABLE LABELS d1 'Record ID'.
> VARIABLE LABELS d2 'Data di completamento'.
> VARIABLE LABELS d3 'Lingua di partenza'.
> VARIABLE LABELS d4 'Età :'.
> VARIABLE LABELS d5 'Sesso:'.
> VARIABLE LABELS d6 '3 - Papà '.
> VARIABLE LABELS d7 'Com'è composta la tua famiglia? - COMMENT'.
> VARIABLE LABELS d8 '3 - Mamma'.
> VARIABLE LABELS d9 'Com'è composta la tua famiglia? - COMMENT'.
> VARIABLE LABELS d10 '3 - Fratelli n°'.
> VARIABLE LABELS d11 'Com'è composta la tua famiglia? - COMMENT'.
> VARIABLE LABELS d12 '3 - Sorelle n°'.
> VARIABLE LABELS d13 'Com'è composta la tua famiglia? - COMMENT'.
> VARIABLE LABELS d14 '3 - Nonni n°'.
> VARIABLE LABELS d15 'Com'è composta la tua famiglia? - COMMENT'.
> VARIABLE LABELS d16 '3 - Altre figure parentali (zii, cugini, ecc.) n°'.
> VARIABLE LABELS d17 'Com'è composta la tua famiglia? - COMMENT'.
> VARIABLE LABELS d18 '4 - Papà '.
> VARIABLE LABELS d19 'Quali di queste persone vivono in casa con te? 
> - COMMENT'.
> VARIABLE LABELS d20 '4 - Mamma'.
> VARIABLE LABELS d21 'Quali di queste persone vivono in casa con te? 
> - COMMENT'.
> VARIABLE LABELS d22 '4 - Fratelli n°'.
> VARIABLE LABELS d23 'Quali di queste persone vivono in casa con te? 
> - COMMENT'.
> VARIABLE LABELS d24 '4 - Sorelle n°'.
> VARIABLE LABELS d25 'Quali di queste persone vivono in casa con te? 
> - COMMENT'.
> VARIABLE LABELS d26 '4 - Nonni n°'.
> VARIABLE LABELS d27 'Quali di queste persone vivono in casa con te? 
> - COMMENT'.
> VARIABLE LABELS d28 '4 - Altre figure parentali (zii, cugini, ecc.) n°'.
> VARIABLE LABELS d29 'Quali di queste persone vivono in casa con te? 
> - COMMENT'.
>
>
> *Define Value labels.
> VALUE LABELS d5
> 1 "Maschio"
> 2 "Femmina".
> VALUE LABELS d6
> 1 "Sì"
> 0 "Non selezionato".
> VALUE LABELS d8
> 1 "Sì"
> 0 "Non selezionato".
>
>
>
>
> On Tue, Nov 25, 2008 at 10:27 AM, Eik Vettorazzi 
> <E.Vettorazzi at uke.uni-hamburg.de 
> <mailto:E.Vettorazzi at uke.uni-hamburg.de>> wrote:
>
>     Hi Livio,
>     I think you mixed something up. The .sps - files are the syntax
>     files of SPSS, and I think there is no automated way (but I would
>     like to be corrected there) of converting SPSS syntax to R-code.
>     The usual data files of spss  have the extension .sav. Such files
>     can easily read by read.spss (package foreign) or spss.get
>     (package Hmisc), if you think the variable labels of SPSS are
>     fancy the latter approach is possibly more appropriate, because it
>     adds an attribute with this label to each row.
>     hth.
>
>
>
>     livio finos schrieb:
>
>         Hi everyone,
>         I'm trying to import .sps (SPSS portable file) file.
>         the read.spss function (library foreign) doesn't allow to
>         import such files.
>         should I import in spss and then save as sav file? there is
>         not other
>         solutions available?
>         what I mostly like from spss file is that they have variable
>         labels.
>         want is really wish to keep are the variable.labels from the
>         spss file; so,
>         if there is a different way to bring them from the sps file
>         will be also ok
>         (I also have a csv copy but without the variable.labels
>         obviously).
>         thanks for any answer..
>          livio
>
>                [[alternative HTML version deleted]]
>
>         ______________________________________________
>         R-help at r-project.org <mailto:R-help at r-project.org> mailing list
>         https://stat.ethz.ch/mailman/listinfo/r-help
>         PLEASE do read the posting guide
>         http://www.R-project.org/posting-guide.html
>         and provide commented, minimal, self-contained, reproducible code.
>          
>
>
>     -- 
>     Eik Vettorazzi
>     Institut für Medizinische Biometrie und Epidemiologie
>     Universitätsklinikum Hamburg-Eppendorf
>
>     Martinistr. 52
>     20246 Hamburg
>
>     T ++49/40/42803-8243
>     F ++49/40/42803-7790
>
>



More information about the R-help mailing list