Hello Stata community,
I am trying to replace multiple id of a data set, where the ids are consecutive numbers.
What I need:
replace new_id=149 if man==1 & count_man==1
replace new_id=150 if man==1 & count_man==2
replace new_id=151 if man==1 & count_man==3
replace new_id=152 if man==1 & count_man==4
replace new_id=153 if man==1 & count_man==5
replace new_id=154 if man==1 & count_man==6
replace new_id=155 if man==1 & count_man==7
replace new_id=156 if man==1 & count_man==8
replace new_id=157 if man==1 & count_man==9
I have about 100 ids that need to be changed, therefore I am trying to run a loop. I have tried the following code, but it does not change anything
local obs=1
forvalues x=149/271 {
forvalues i=1/117 {
replace new_id= `x' if man==1 & count_man==`i' in `obs'
}
}
Any suggestions?
Best,
Tatiana
Related Posts with Loop with consecutive numbers
pairwise combination.Dear All, I find this question here (https://bbs.pinggu.org/thread-7317333-1-1.html). Suppose that t…
How to find value for upper adjacent value in boxplot?I would like to know the value of the upper adjacent value in a boxplot I have, so that I can exclud…
Collapse using both string and alphanumericI am trying to collapse three (ultimately more) variables on zip codes, state names, and Congression…
graph bar with several categorical variableshi stata users i would like to do this graph in stata; it's about different services and with a lik…
Help ppml Stata 15Hi, I am trying to run this command on Stata 15: ppml trade EXPORTER_TIME_FE* IMPORTER_TIME_FE* ln…
Subscribe to:
Post Comments (Atom)
0 Response to Loop with consecutive numbers
Post a Comment