Re: [R] SPSS long variable names
The problem is the limit of 8 characters long on variable names.[in read.spss??] I just created a file in SPSS 17 and saved it in standard format (.sav) The file had four unique variable NAMES which were much longer than 8 characters (although not 64). I entered two rows of data and saved the file again. The variable view in SPSS looked like the following for the 4 variables I created. (unique in the first postition after the first 9) a12345678901234567890987654321098765432011 Numeric 8 2 a1234567890 None None 14 Right Scale a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 Right Scale a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None 14 Left Nominal a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None 14 Right Scale I now started R and used read.spss() from the foreign package using the following code The data frame I read in seemed to reflect the original file with respect to column names: library(foreign) c=read.spss(file.choose(),to.data.frame=TRUE) c a12345678901234567890987654321098765432011 a1234567899123456789098765432109876543201 a1234567898123456789098765432109876543201 1 33.3 13452825600 a cat 2 22.2 1346328 dog a1234567897123456789098765432109876543201 1 32165 2 321654987 It appears these long variable names read in just fine. Thus, I would ask caveman whether the problem is really an R problem at all, or is it a problem with PSPP writing (in which case this would be the wrong list to be discussing it on)? R __ R-help@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.
Re: [R] SPSS long variable names
Impressive! PSPP produces the sav fine. The sav file produced by the PSPP is seen by SPSS (16) with the long names. I attach my sav produced by the PSPP. And I start to suspect my foreign package version: I am using 0.8.26-1 from the r-cran-foreign a Ubuntu 8.10 package. Can you tell me your version? I am updating mine. Thanks guys. Caveman On Thu, Oct 15, 2009 at 9:02 PM, Robert Baer rb...@atsu.edu wrote: The problem is the limit of 8 characters long on variable names.[in read.spss??] I just created a file in SPSS 17 and saved it in standard format (.sav) The file had four unique variable NAMES which were much longer than 8 characters (although not 64). I entered two rows of data and saved the file again. The variable view in SPSS looked like the following for the 4 variables I created. (unique in the first postition after the first 9) a12345678901234567890987654321098765432011 Numeric 8 2 a1234567890 None None 14 Right Scale a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 Right Scale a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None 14 Left Nominal a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None 14 Right Scale I now started R and used read.spss() from the foreign package using the following code The data frame I read in seemed to reflect the original file with respect to column names: library(foreign) c=read.spss(file.choose(),to.data.frame=TRUE) c a12345678901234567890987654321098765432011 a1234567899123456789098765432109876543201 a1234567898123456789098765432109876543201 1 33.3 13452825600 a cat 2 22.2 1346328 dog a1234567897123456789098765432109876543201 1 32165 2 321654987 It appears these long variable names read in just fine. Thus, I would ask caveman whether the problem is really an R problem at all, or is it a problem with PSPP writing (in which case this would be the wrong list to be discussing it on)? R __ R-help@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.
Re: [R] SPSS long variable names
Robert you are right. I updated the foreign package and I can read long names now I have checked the changelog and I found that long names reading were introduced after 0.8.29 while I were using 0.8.26-1. So I am really sorry guys for this mess. R can read long names. Caveman On Thu, Oct 15, 2009 at 9:42 PM, Orvalho Augusto orvaq...@gmail.com wrote: Impressive! PSPP produces the sav fine. The sav file produced by the PSPP is seen by SPSS (16) with the long names. I attach my sav produced by the PSPP. And I start to suspect my foreign package version: I am using 0.8.26-1 from the r-cran-foreign a Ubuntu 8.10 package. Can you tell me your version? I am updating mine. Thanks guys. Caveman On Thu, Oct 15, 2009 at 9:02 PM, Robert Baer rb...@atsu.edu wrote: The problem is the limit of 8 characters long on variable names.[in read.spss??] I just created a file in SPSS 17 and saved it in standard format (.sav) The file had four unique variable NAMES which were much longer than 8 characters (although not 64). I entered two rows of data and saved the file again. The variable view in SPSS looked like the following for the 4 variables I created. (unique in the first postition after the first 9) a12345678901234567890987654321098765432011 Numeric 8 2 a1234567890 None None 14 Right Scale a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 Right Scale a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None 14 Left Nominal a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None 14 Right Scale I now started R and used read.spss() from the foreign package using the following code The data frame I read in seemed to reflect the original file with respect to column names: library(foreign) c=read.spss(file.choose(),to.data.frame=TRUE) c a12345678901234567890987654321098765432011 a1234567899123456789098765432109876543201 a1234567898123456789098765432109876543201 1 33.3 13452825600 a cat 2 22.2 1346328 dog a1234567897123456789098765432109876543201 1 32165 2 321654987 It appears these long variable names read in just fine. Thus, I would ask caveman whether the problem is really an R problem at all, or is it a problem with PSPP writing (in which case this would be the wrong list to be discussing it on)? R __ R-help@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.
Re: [R] SPSS long variable names
The problem is the limit of 8 characters long on variable names. And again, my answer is that one approach would be to map SHORT names to long variable LABELS. This was a common use of labels before variable names supported 64 bytes. After reading into R with read.spss() you and easily replace the short R names with the long LABELS to form long R names. If for for some reason you are unwilling to give up some existing LABELS that are not, you could create some dummy variables for just this mapping purpose. - Original Message - From: Orvalho Augusto orvaq...@gmail.com To: Robert Baer rb...@atsu.edu Cc: r-help@r-project.org Sent: Tuesday, October 13, 2009 10:39 AM Subject: Re: [R] SPSS long variable names No! That is variable labels. Caveman On Tue, Oct 13, 2009 at 4:52 PM, Robert Baer rb...@atsu.edu wrote: I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. This sequence seems to access the long filenames for me if I know what you are asking for: library('foreign') a-read.spss('fil.sav') lnames - attr(a,variable.labels,exact=FALSE) Rob __ R-help@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.
Re: [R] SPSS long variable names
On Wed, Oct 14, 2009 at 2:45 PM, Robert Baer rb...@atsu.edu wrote: The problem is the limit of 8 characters long on variable names. And again, my answer is that one approach would be to map SHORT names to long variable LABELS. This was a common use of labels before variable names supported 64 bytes. After reading into R with read.spss() you and easily replace the short R names with the long LABELS to form long R names. If for for some reason you are unwilling to give up some existing LABELS that are not, you could create some dummy variables for just this mapping purpose. Dear Robert, the problem with this approach is that : 1) if the first 8 characters of some variable names in the SPSS dataset are the same, you'd get confusing results. Mapping the labels on the short names might get complicated too, although I'm not sure on that. 2) data labels can contain spaces (and often do), so they cannot be readily used as variable names in R. Cheers Joris - Original Message - From: Orvalho Augusto orvaq...@gmail.com To: Robert Baer rb...@atsu.edu Cc: r-help@r-project.org Sent: Tuesday, October 13, 2009 10:39 AM Subject: Re: [R] SPSS long variable names No! That is variable labels. Caveman On Tue, Oct 13, 2009 at 4:52 PM, Robert Baer rb...@atsu.edu wrote: I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. This sequence seems to access the long filenames for me if I know what you are asking for: library('foreign') a-read.spss('fil.sav') lnames - attr(a,variable.labels,exact=FALSE) Rob __ R-help@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. __ R-help@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.
Re: [R] SPSS long variable names
Hi The .dat file is a tab delimited file with the long variables names on it. The .sps file has the instructions to read the .dat and place all the variable and value labels. The ideia of reading the dat directely is good but I need the labels placed. Yes I could read the dat file and parese myself the sps to get sps file but that it is a job that to try and by these mails I will have to do so. For now what I made a little script to generate the sav using pspp; Then I read the sav with read.spss. Then I call read.delim to read the long names on the dat file. It works but is not beautfull and uses more resources. The great thing would be to support long variables names on read.spss. Thanks guys for everything Caveman On Wed, Oct 14, 2009 at 4:52 PM, joris meys jorism...@gmail.com wrote: Hi Orvalho, question : where do the .dat files come from and what do you have to do with the SPSS syntax files. I guess the syntax file is to change the .dat file into SPSS format. But you could take the shortcut and read in the .dat file directly. If the SPSS syntax file is a text file (which should be), you can construct your own function to read in all specifications from the syntax file. the function regexp() can be a great help for that. If you have no clue how to do that, just send me an example, and I'll take a look. Cheers Joris On Sat, Oct 10, 2009 at 6:14 PM, Orvalho Augusto orvaq...@gmail.com wrote: Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. __ R-help@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.
Re: [R] SPSS long variable names
You could read in the sps file in R with readLines() for example, and then use the tools for regular expression and substring to find the label statements. Then you can just use R to add the labels to it, without having to pass through PSPP. So you could actually just create an R script that takes both files as input, and generates the output automatically. I's prefer to do it that way than to use YAP (yet another program), while waiting for the adaptation of read.spss... Cheers Joris On Wed, Oct 14, 2009 at 5:48 PM, Orvalho Augusto orvaq...@gmail.com wrote: Hi The .dat file is a tab delimited file with the long variables names on it. The .sps file has the instructions to read the .dat and place all the variable and value labels. The ideia of reading the dat directely is good but I need the labels placed. Yes I could read the dat file and parese myself the sps to get sps file but that it is a job that to try and by these mails I will have to do so. For now what I made a little script to generate the sav using pspp; Then I read the sav with read.spss. Then I call read.delim to read the long names on the dat file. It works but is not beautfull and uses more resources. The great thing would be to support long variables names on read.spss. Thanks guys for everything Caveman On Wed, Oct 14, 2009 at 4:52 PM, joris meys jorism...@gmail.com wrote: Hi Orvalho, question : where do the .dat files come from and what do you have to do with the SPSS syntax files. I guess the syntax file is to change the .dat file into SPSS format. But you could take the shortcut and read in the .dat file directly. If the SPSS syntax file is a text file (which should be), you can construct your own function to read in all specifications from the syntax file. the function regexp() can be a great help for that. If you have no clue how to do that, just send me an example, and I'll take a look. Cheers Joris On Sat, Oct 10, 2009 at 6:14 PM, Orvalho Augusto orvaq...@gmail.com wrote: Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. __ R-help@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.
Re: [R] SPSS long variable names
Ok. I will try that then. Caveman On Wed, Oct 14, 2009 at 6:53 PM, joris meys jorism...@gmail.com wrote: You could read in the sps file in R with readLines() for example, and then use the tools for regular expression and substring to find the label statements. Then you can just use R to add the labels to it, without having to pass through PSPP. So you could actually just create an R script that takes both files as input, and generates the output automatically. I's prefer to do it that way than to use YAP (yet another program), while waiting for the adaptation of read.spss... Cheers Joris On Wed, Oct 14, 2009 at 5:48 PM, Orvalho Augusto orvaq...@gmail.com wrote: Hi The .dat file is a tab delimited file with the long variables names on it. The .sps file has the instructions to read the .dat and place all the variable and value labels. The ideia of reading the dat directely is good but I need the labels placed. Yes I could read the dat file and parese myself the sps to get sps file but that it is a job that to try and by these mails I will have to do so. For now what I made a little script to generate the sav using pspp; Then I read the sav with read.spss. Then I call read.delim to read the long names on the dat file. It works but is not beautfull and uses more resources. The great thing would be to support long variables names on read.spss. Thanks guys for everything Caveman On Wed, Oct 14, 2009 at 4:52 PM, joris meys jorism...@gmail.com wrote: Hi Orvalho, question : where do the .dat files come from and what do you have to do with the SPSS syntax files. I guess the syntax file is to change the .dat file into SPSS format. But you could take the shortcut and read in the .dat file directly. If the SPSS syntax file is a text file (which should be), you can construct your own function to read in all specifications from the syntax file. the function regexp() can be a great help for that. If you have no clue how to do that, just send me an example, and I'll take a look. Cheers Joris On Sat, Oct 10, 2009 at 6:14 PM, Orvalho Augusto orvaq...@gmail.com wrote: Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. __ R-help@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.
Re: [R] SPSS long variable names
library(Hmisc) spss.get may do it but it's been some time since I used it. --- On Sat, 10/10/09, Orvalho Augusto orvaq...@gmail.com wrote: From: Orvalho Augusto orvaq...@gmail.com Subject: [R] SPSS long variable names To: r-help@r-project.org Received: Saturday, October 10, 2009, 12:14 PM Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimiz etexplorer/ __ R-help@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.
Re: [R] SPSS long variable names
Thanks for the answer. Hmisc uses read.spss from the foreign package. And so it does not solve my trouble. I need to read the long names on the SPSS dataset. Caveman On Tue, Oct 13, 2009 at 3:01 PM, John Kane jrkrid...@yahoo.ca wrote: library(Hmisc) spss.get may do it but it's been some time since I used it. --- On Sat, 10/10/09, Orvalho Augusto orvaq...@gmail.com wrote: From: Orvalho Augusto orvaq...@gmail.com Subject: [R] SPSS long variable names To: r-help@r-project.org Received: Saturday, October 10, 2009, 12:14 PM Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ __ R-help@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.
Re: [R] SPSS long variable names
Sorry to be so blunt, but I cannot believe PSPP can't save a dataset as a .csv file for example. That should be the prefered format to transport a dataset to any other statistical package, including R. csv files are universal. Cheers Joris On Tue, Oct 13, 2009 at 3:30 PM, Orvalho Augusto orvaq...@gmail.com wrote: Thanks for the answer. Hmisc uses read.spss from the foreign package. And so it does not solve my trouble. I need to read the long names on the SPSS dataset. Caveman On Tue, Oct 13, 2009 at 3:01 PM, John Kane jrkrid...@yahoo.ca wrote: library(Hmisc) spss.get may do it but it's been some time since I used it. --- On Sat, 10/10/09, Orvalho Augusto orvaq...@gmail.com wrote: From: Orvalho Augusto orvaq...@gmail.com Subject: [R] SPSS long variable names To: r-help@r-project.org Received: Saturday, October 10, 2009, 12:14 PM Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ __ R-help@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. __ R-help@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.
Re: [R] SPSS long variable names
Thanks guys for the greaty ideia!! I am fool because I did not realize that before. Caveman On Tue, Oct 13, 2009 at 4:41 PM, joris meys jorism...@gmail.com wrote: Just for clarity : the csv format will solve your problem, as the restrictions on the variable names will only depend on the program you use to load them. I never experienced problems with variable names using csv to switch datasets between SPlus, R, SAS and SPSS. Cheers Joris On Tue, Oct 13, 2009 at 4:35 PM, joris meys jorism...@gmail.com wrote: Sorry to be so blunt, but I cannot believe PSPP can't save a dataset as a .csv file for example. That should be the prefered format to transport a dataset to any other statistical package, including R. csv files are universal. Cheers Joris On Tue, Oct 13, 2009 at 3:30 PM, Orvalho Augusto orvaq...@gmail.com wrote: Thanks for the answer. Hmisc uses read.spss from the foreign package. And so it does not solve my trouble. I need to read the long names on the SPSS dataset. Caveman On Tue, Oct 13, 2009 at 3:01 PM, John Kane jrkrid...@yahoo.ca wrote: library(Hmisc) spss.get may do it but it's been some time since I used it. --- On Sat, 10/10/09, Orvalho Augusto orvaq...@gmail.com wrote: From: Orvalho Augusto orvaq...@gmail.com Subject: [R] SPSS long variable names To: r-help@r-project.org Received: Saturday, October 10, 2009, 12:14 PM Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ __ R-help@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. __ R-help@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.
Re: [R] SPSS long variable names
- Original Message - From: Robert Baer rb...@atsu.edu To: Orvalho Augusto orvaq...@gmail.com Sent: Tuesday, October 13, 2009 9:52 AM Subject: Re: [R] SPSS long variable names I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. This sequence seems to access the long filenames for me if I know what you are asking for: library('foreign') a-read.spss('fil.sav') lnames - attr(a,variable.labels,exact=FALSE) Rob __ R-help@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.
Re: [R] SPSS long variable names
No! That is variable labels. Caveman On Tue, Oct 13, 2009 at 4:52 PM, Robert Baer rb...@atsu.edu wrote: I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. This sequence seems to access the long filenames for me if I know what you are asking for: library('foreign') a-read.spss('fil.sav') lnames - attr(a,variable.labels,exact=FALSE) Rob __ R-help@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.
Re: [R] SPSS long variable names
Sadlly exportation to csv or another format is not implemented yet: http://www.gnu.org/software/pspp/manual/html_node/Not-Implemented.html Caveman On Tue, Oct 13, 2009 at 4:41 PM, joris meys jorism...@gmail.com wrote: Just for clarity : the csv format will solve your problem, as the restrictions on the variable names will only depend on the program you use to load them. I never experienced problems with variable names using csv to switch datasets between SPlus, R, SAS and SPSS. Cheers Joris On Tue, Oct 13, 2009 at 4:35 PM, joris meys jorism...@gmail.com wrote: Sorry to be so blunt, but I cannot believe PSPP can't save a dataset as a .csv file for example. That should be the prefered format to transport a dataset to any other statistical package, including R. csv files are universal. Cheers Joris On Tue, Oct 13, 2009 at 3:30 PM, Orvalho Augusto orvaq...@gmail.com wrote: Thanks for the answer. Hmisc uses read.spss from the foreign package. And so it does not solve my trouble. I need to read the long names on the SPSS dataset. Caveman On Tue, Oct 13, 2009 at 3:01 PM, John Kane jrkrid...@yahoo.ca wrote: library(Hmisc) spss.get may do it but it's been some time since I used it. --- On Sat, 10/10/09, Orvalho Augusto orvaq...@gmail.com wrote: From: Orvalho Augusto orvaq...@gmail.com Subject: [R] SPSS long variable names To: r-help@r-project.org Received: Saturday, October 10, 2009, 12:14 PM Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ __ R-help@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. __ R-help@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.
Re: [R] SPSS long variable names
Orvalho Augusto wrote: Sadlly exportation to csv or another format is not implemented yet: http://www.gnu.org/software/pspp/manual/html_node/Not-Implemented.html Caveman That would not solve the problem anyway because you would not get labels and other variable attributes. Frank On Tue, Oct 13, 2009 at 4:41 PM, joris meys jorism...@gmail.com wrote: Just for clarity : the csv format will solve your problem, as the restrictions on the variable names will only depend on the program you use to load them. I never experienced problems with variable names using csv to switch datasets between SPlus, R, SAS and SPSS. Cheers Joris On Tue, Oct 13, 2009 at 4:35 PM, joris meys jorism...@gmail.com wrote: Sorry to be so blunt, but I cannot believe PSPP can't save a dataset as a .csv file for example. That should be the prefered format to transport a dataset to any other statistical package, including R. csv files are universal. Cheers Joris On Tue, Oct 13, 2009 at 3:30 PM, Orvalho Augusto orvaq...@gmail.com wrote: Thanks for the answer. Hmisc uses read.spss from the foreign package. And so it does not solve my trouble. I need to read the long names on the SPSS dataset. Caveman On Tue, Oct 13, 2009 at 3:01 PM, John Kane jrkrid...@yahoo.ca wrote: library(Hmisc) spss.get may do it but it's been some time since I used it. --- On Sat, 10/10/09, Orvalho Augusto orvaq...@gmail.com wrote: From: Orvalho Augusto orvaq...@gmail.com Subject: [R] SPSS long variable names To: r-help@r-project.org Received: Saturday, October 10, 2009, 12:14 PM Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ R-help@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. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@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.