[R] Converting ddf/dct/sas data definition file to R

Stephan Lindner lindners at umich.edu
Thu Jan 22 19:48:55 CET 2009


Dear all,

I was wondering whether anyone knows about a program which converts
(part of) a data definition file (such as a .dct file for stata, or
.sas file for sas) into an R-script.

Here is an example with a .sas file: 

<-- snipp 

VALUE HTYPE   	(default=32)
	0         =  "Not in household"              
	1         =  "Married couple family household"
	2         =  "Male householder family"       
	3         =  "Female householder family"     
	4         =  "Male householder nonfamily"    
	5         =  "Female householder nonfamily"  
	6         =  "Group quarters"                
;

snapp --> 


This entry defines the variable HTYPE as a factor and assigns levels
and labels. Ideally, it would be transformed into the following entry
in R:


data.frame$HTYPE <- factor(data.frame$HTYPE,
	levels=c(0,1,2,3,4,5,6),
	labels=c("Not in household",              
		 "Married couple family household",
		 "Male householder family",       
		 "Female householder family",     
		 "Male householder nonfamily",    
		 "Female householder nonfamily",  
		 "Group quarters"
                )
	)

                
Of course, this can be done by hand and isn't too bad with a good text
editor. The reason why I am looking for a program is because I have a
bunch of datasets (about 100) and there are about 200 variables defined
per dataset. My goal is to provide R-scripts for these datasets such
that the data files can be read in with R, making them accessible for
R users. 



Thanks! 


	Stephan






-- 
-----------------------
Stephan Lindner
University of Michigan




More information about the R-help mailing list