Hi all,
Although I was going through some of the website links, I could not solve my issue. So, I am posting here and seeking the help. My issue is that I need to generate manynew dummy varaibles out of a categorical variable. For example the variable name is districtname_main which is a string type and it has 32 districts (See the attached picture). I have to gen all of them into new binary dummy variables with the var name and label name of that particular district. So I tried the following command but did not work.
foreach var of districtname_main {
gen dist_`var'=0
replace dist_`var'=1 if districtname_main ==real("`var'")
}
I also tried many other methods suggested on various websites. But nothing worked. I wonder if someone could help me out from this issue.
Related Posts with generating many dummy variables with the var name and label name
How to refers the last n rows or obs in StataHi! I have a dataset with prices of stocks. It is a data panel by Code (the ticker of the stock) and…
How to perform repeat sales regression on housing dataDear all, I would like to perform a repeat sales analysis based on housing data from the American H…
!= 1 predicts failure perfectly note: 0b.HX_HTN != 1 predicts failure perfectly 0b.HX_HTN dropped and 14 obs not used note: 0b.H…
Merging data using unique identifierDear My dataset is split across two large files. the master file has 10,000 respondents all uniquely…
Truncating the most extreme 1 percent of cash from operationsHi all, I have to truncate the most extreme 1 percent of cash from operations (CFO_0). Is the follo…
Subscribe to:
Post Comments (Atom)
0 Response to generating many dummy variables with the var name and label name
Post a Comment