I've been trying to get some data from the National Survey for Family Growth into R - however, the data is in a .dat file and the data I need doesn't have any spaces or commas separating fields - rather you have to look into the codebook and what number of digits along the line the data you need is. The data I want are the following, where 1,12,int means that the data I'm interested starts in column 1 and finishes in column 12 and is an integer. ('caseid', 1, 12, int), ('nbrnaliv', 22, 22, int), ('babysex', 56, 56, int), ('birthwgt_lb', 57, 58, int), ('birthwgt_oz', 59, 60, int), ('prglength', 275, 276, int), ('outcome', 277, 277, int), ('birthord', 278, 279, int), ('agepreg', 284, 287, int), ('finalwgt', 423, 440, float) How can I do this using R? I've written a python programme which basically does it but it'd be nicer if I could skip the Python bit and just do it using R. Cheers for any help. -- View this message in context: http://r.789695.n4.nabble.com/Getting-codebook-data-into-R-tp4374329p4374329.html Sent from the R help mailing list archive at Nabble.com.
I've been trying to get some data from the National Survey for Family Growth into R - however, the data is in a .dat file and the data I need doesn't have any spaces or commas separating fields - rather you have to look into the codebook and what number of digits along the line the data you need is. The data I want are the following, where 1,12,int means that the data I'm interested starts in column 1 and finishes in column 12 and is an integer. ('caseid', 1, 12, int), ('nbrnaliv', 22, 22, int), ('babysex', 56, 56, int), ('birthwgt_lb', 57, 58, int), ('birthwgt_oz', 59, 60, int), ('prglength', 275, 276, int), ('outcome', 277, 277, int), ('birthord', 278, 279, int), ('agepreg', 284, 287, int), ('finalwgt', 423, 440, float) How can I do this using R? I've written a python programme which basically does it but it'd be nicer if I could skip the Python bit and just do it using R. Cheers for any help. -- View this message in context: http://r.789695.n4.nabble.com/Getting-codebook-data-into-R-tp4374331p4374331.html Sent from the R help mailing list archive at Nabble.com.
I've been trying to get some data from the National Survey for Family Growth into R - however, the data is in a .dat file and the data I need doesn't have any spaces or commas separating fields - rather you have to look into the codebook and what number of digits along the line the data you need is. The data I want are the following, where 1,12,int means that the data I'm interested starts in column 1 and finishes in column 12 and is an integer. ('caseid', 1, 12, int), ('nbrnaliv', 22, 22, int), ('babysex', 56, 56, int), ('birthwgt_lb', 57, 58, int), ('birthwgt_oz', 59, 60, int), ('prglength', 275, 276, int), ('outcome', 277, 277, int), ('birthord', 278, 279, int), ('agepreg', 284, 287, int), ('finalwgt', 423, 440, float) How can I do this using R? I've written a python programme which basically does it but it'd be nicer if I could skip the Python bit and just do it using R. Cheers for any help. -- View this message in context: http://r.789695.n4.nabble.com/Getting-codebook-data-into-R-tp4374330p4374330.html Sent from the R help mailing list archive at Nabble.com.
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of barny > Sent: Saturday, February 11, 2012 10:04 AM > To: r-help at r-project.org > Subject: Re: [R] Getting codebook data into R > > Hi Eric - after seeing the difficulty of inputting this kind of data into > R I > decided to use your method. It was rather painless using PSPP to do what I > wanted - however, how do I now create an SPSS file and then use the memisc > package to read it in? >There is SPSS code for reading the files on the codebook page http://www.cdc.gov/nchs/nsfg/nsfg_2006_2010_puf.htm#codebooks hope this is helpful, Dan Daniel Nordlund Bothell, WA USA
This is how I get a whole SPSS data files into R. You specifically asked about the codebook, so this may not be exactly what you are after. spssFileInfo <- spss.system.file ( file = "path to my SPSS file" ) spssDataSet <- as.data.set ( spssFileInfo) spssDataFrame <- as.data.frame ( spssDataSet ) (Not tested. Adapted from working code.) memisc documentation has more info about doing this and how it works. eRic ----- Original message ----- From: "barny" <garyb.davies at btinternet.com> To: r-help at r-project.org Date: Sat, 11 Feb 2012 10:04:16 -0800 (PST) Subject: Re: [R] Getting codebook data into R Hi Eric - after seeing the difficulty of inputting this kind of data into R I decided to use your method. It was rather painless using PSPP to do what I wanted - however, how do I now create an SPSS file and then use the memisc package to read it in? -- View this message in context: http://r.789695.n4.nabble.com/Getting-codebook-data-into-R-tp4374331p4379433.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.