Convert DDF files describing e.g. US Census data to Stata dct and do files
ddf2dct using filename1 [, dct(filename2) do(filename3) data(filename4) drop(varlist) keep(varlist) replace noinfile]
Description
ddf2dct converts Data Definition File (DDF) format files to Stata dct and do files. A DDF file contains entries of the form
------------------------------------------------------------------------- D SREFMON 1 25 T SU: Reference month of this record Universe=All persons V 1 .First Reference month V 2 .Second Reference month V 3 .Third Reference month V 4 .Fourth Reference month -------------------------------------------------------------------------
designed to allow mainframe users to infile data, and is often distributed with data following standard US Census formats, e.g. the Decennial Census (see also http://www.nber.org/data/pums.html), the Survey of Income and Program Participation (SIPP: see also http://www.nber.org/data/sipp.html), and the Current Population Survey (CPS: see also http://www.nber.org/cps/).
All variable names are converted to lower case. Variable names in DDF files are not guaranteed to be legal in Stata, so the following substitutions are made:
% becomes p - becomes _ $ becomes d and any variables names that are repeated in the data dictionary have a number added to the end of their name high enough to make the name distinct from all previously defined names. Thus, if a variable FILLER appears four times in the DDF file, the dct file will have variables filler, filler1, filler2, and filler3.
Options
dct(filename2) specifies a path and filename where a dictionary file should be saved.
do(filename3) specifies a path and filename where a do file that infiles data and assigns value labels should be saved.
data(filename4) specifies a path and filename where raw data (to be infiled) is saved.
drop(varlist) excludes the variables specified from the dct file.
keep(varlist) includes only the variables specified in the dct file.
replace specifies that the files named may be overwritten if they exist already.
noinfile requests no infile command in the created do file.
Examples
------------------------------------------------------------------------- clear tempfile do dct s96 ddf2dct using http://www.nber.org/sipp/1996/sipp96l.ddf, dct(`dct') do(`do') run `do' describe t??amt notes t50 save `s96' tempfile do dct s01 ddf2dct using http://www.nber.org/sipp/2001/sipp01w1.ddf, dct(`dct') do(`do') clear run `do' notes t50 tempfile do dct s93 ddf2dct using http://www.nber.org/sipp/1993/sipp93w1.ddf, dct(`dct') do(`do') clear run `do' notes higrade ssc install vlc, replace save `s93' vlc higrade, to(`s96') use `s96', clear vlc eeducate, to(`s93') ------------------------------------------------------------------------- clear tempfile do dct c89 ddf2dct using http://www.nber.org/cps/cpsmar89_91.doc, dct(`dct') do(`do') drop(FILLER) run `do' save `c89' clear tempfile do dct c92 ddf2dct using http://www.nber.org/cps/cpsmar92.ddf, dct(`dct') do(`do') drop(FILLER) run `do' save `c92' ssc install vlc, replace vlc a_hga, to(`c89') g lab92=trim(substr(label1,1,25) ren label2 lab91 li val lab91 lab92, noo clean -------------------------------------------------------------------------
Author
Austin Nichols Urban Institute Washington, DC austinnichols@gmail.com
Also see
On-line: help for infiling, label, labelbook, vlc