I have 9 .txt files containing data, one for each year from 2010 to 2018. All files share the same naming convention; the only thing that differs is the year. These data files require a dictionary to be read in. Each file needs the same dictionary; however, I need to specify which file is being read in at the beginning of the dictionary file and I don't see a way to loop. Is there a way to do this elegantly--i.e., without having to create a separate .dct file for each data file? Ultimately, I'd like to read in the first file, 2010, using the dictionary, save the data as a .dta file, then do the same for the subsequent years. Then, I would like to append all the .dta files.
From my .do file:
My dictionary file (there are many more variables than this, but I cut most out to save space):
From my .do file:
Code:
infile using "S:\Project\CDC_Dictionary.dct"
Code:
dictionary using "S:\Project\Mort2010US.txt" { str39 race %39s "Race" str5 hisp %5s "Hispanic origin" str2 race_recode_40 %2s "Race recode 40" }
Comment