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
-esttab-: eform only for some equations in a multi-equation model?Hi, I have a multi-equation model that I would like to get into an -esttab- table. That's easy. The…
simple programming questionI have three variables: a FIRM(i.e company) identifier, a YEAR value, and a CODE value. I want to co…
semipari would like to save standard errors after semipar run. Please help …
convert strL to str#I tried to convert my key variable "name" from strL to str# to merge two datasets. However, the erro…
Which model to use?I have a panel of companies, their advertising levels, and public sentiment. I am trying to estimate…
Subscribe to:
Post Comments (Atom)
0 Response to Assigning preferred IDs to to District Names of a large Panel Dataset
Post a Comment