Hello, I have year-wise data files which have household level data on wide-ranging variables. The problem is that in the early years of this data collection, the districts were assigned one type of IDs. Then in later years the IDs for districts changed. It should not be a problem if each dataset is analyzed separately. However, I am to append multiple years' data so that a panel analysis could be conducted. I am facing this hurdle of districts having different IDs in different Years. Luckily, district names are available. However, I cannot follow stata's value-assigning (talking about "encode" command) process for string variables because number of districts also vary for some of the years (the geo-politics inside the country has made some districts to merge and some districts to get divided into more than 1).
So, to summarize, I have two types of IDs for districts in different years. Early year datasets in which IDs are from 1 to 221 and later datasets in which IDs range from 146 to 326. I need to change early year's IDs to latter's. I had an excel file with Old IDs and New IDs and District names. I imported the excel file to a new stata file and tried to do a loop within a loop to generate a new variable which would take on the new ID according to the old district ID or district name. The simplest but extremely exhausting way would be to However, being a bit new to looping in stata, I am facing multiple issues:
gen updatedID =.
forvalues i=1/221 {
forvalues j=146/326 {
replace updatedID = `j' if districtID==`i'
}
}
**in place of districtID i also tried using districtName but the problem is in the loop. I want that after updatedID takes a value of 146 in front of districtID==1, districtID should move to ==2, but I am not sure how to do that. Also, I tried similar with encoded district names as well, but didnt work. Some help here would be much appreciated. Thanks.
p.s: this is my first post here so if there's any relevant information that's missing, please let me know.
Related Posts with Assigning preferred IDs to to District Names of a large Panel Dataset
Panel data, Stata omits i.Year dummies due to collinearityHi all, I am fairly new to Stata and I ran into a problem with my panel data set. My data set consi…
Running time for QUAIDSHi, I'm currently running QUAIDS estimation for 300K households and 215 food items. I wonder how lon…
mrgraph error - variables R _variables do not uniquely identify the observationsI am trying to get a graph for a multiple response question. I have read the resource and the mrtab …
Comparing two CoefficientsHello there, i have split my sample into two parts and ran a fe regression for both of them. is it…
New version of wridit on SSCThanks as always to Kit Baum, a new version of the wridit package is now available for download from…
Subscribe to:
Post Comments (Atom)
0 Response to Assigning preferred IDs to to District Names of a large Panel Dataset
Post a Comment