I am having trouble with the following problem:
I have to merge 2 files. One is already loaded to Stata, the other one is from a weblink.
I am able to figure out how to use the tempfiles to merge them, however one of them needs some complex editing before merging.
These are the datasets I have to merge:
1- The one already in Stata (this is the full data set)
Array
And I have to merge this one: https://www.census.gov/eos/www/naics...ics_2_6_02.txt
And add a column to the first one with the Title corresponding to the specific NAICS code.
The problem is that some codes from the second dataset state a range like: 31-33 Manufacturing, and I'm not capable of merging a value of 32 in the original dataset with this one. (This happens for 31-33, 44-45; 48-49)
Moreover, the dataset from the weblink is .txt and is not delimited with either commas or a specific number of spaces. They have different numbers of spaces after the code. (obs. the naics_codes in my first dataset always have 2 values)
Ideas I had so far: To find the rows with the ranges
Code:
generate SomeNewVariable = cond(strpos(v1,"-")==3, 1,0)
I am really lost and any help would be very much appreciated.
Thank you
Afonso
0 Response to Complex Editing before Merging Datasets
Post a Comment