Hi everyone!
This is my first post here so I hope I am following the correct protocol. I am currently working with a database and I have run into a small problem. I will try to explain this in detail. pensy_ss is a dummy that is set as 1 if PY100G (pension value) falls within the specified interval
What I need to do is the following:
I have a database where each case (or line) represents a certain amount of individuals with similar characteristics according to the weight assigned to them (RB050). I have received some new data that I need to incorporate into my database. This tells me the number (numpensy2) of beneficiaries of social security pension according to age and gives me an average pension value (pensy2). Now I have succeeded in appending these new variables to my database but since numpensy2 is a real number I have to work a little magic to make this work.
So what I want to do is to create a loop that for each age it runs while numpensy2 is higher than the sum of the individuals that have an average pension (pensy_ss: dummy variable) that falls within an interval, where the interval increases by 1 each way every loop (sounds a little confusing but I think the code can help you understand where I am trying to get at).
foreach x in age 45/80 {
while (pensycounter < numpensy2) {
replace pensy_ss=1 if (PY100G>=pensy3 & PY100G<pensy4 & age==`x'
local i = `i' + 1
replace pensy3=pensy2 - `i' if age==`x' // expands my interval //
replace pensy4=pensy2 + `i' if age==`x'
replace counter = (pensy_ss*RB050) if age==`x'
replace pensycounter = sum (counter) if age==`x'
if (pensycounter >= numpensy2 ) continue, break
}
}
Here is a description of the code step by step:
1 - Create age loop from 45 to 80
2 - Condition to keep going until false: while pensycounter is smaller than numpensy2 keep running the following code.
3 - If PY100G (pension value) falls within the specified interval set pensy_ss as 1
4 - Increase my local by 1 every run.
5 - Expand my interval by `x' each way
6 - Check the sum of the REAL number of individuals represented by each pensy_ss at a given age.
7 - If condition is met get out of loop and go to next age.
It's a little confusing but I hope you can understand it.
When I run the loop literally nothing happens. No error, nothing....but also doesn't do anything else. Anyone has any experience with this type of work that they can share with me? It would be most appreciated.
Best,
Luis Manso
This is my first post here so I hope I am following the correct protocol. I am currently working with a database and I have run into a small problem. I will try to explain this in detail. pensy_ss is a dummy that is set as 1 if PY100G (pension value) falls within the specified interval
What I need to do is the following:
I have a database where each case (or line) represents a certain amount of individuals with similar characteristics according to the weight assigned to them (RB050). I have received some new data that I need to incorporate into my database. This tells me the number (numpensy2) of beneficiaries of social security pension according to age and gives me an average pension value (pensy2). Now I have succeeded in appending these new variables to my database but since numpensy2 is a real number I have to work a little magic to make this work.
So what I want to do is to create a loop that for each age it runs while numpensy2 is higher than the sum of the individuals that have an average pension (pensy_ss: dummy variable) that falls within an interval, where the interval increases by 1 each way every loop (sounds a little confusing but I think the code can help you understand where I am trying to get at).
foreach x in age 45/80 {
while (pensycounter < numpensy2) {
replace pensy_ss=1 if (PY100G>=pensy3 & PY100G<pensy4 & age==`x'
local i = `i' + 1
replace pensy3=pensy2 - `i' if age==`x' // expands my interval //
replace pensy4=pensy2 + `i' if age==`x'
replace counter = (pensy_ss*RB050) if age==`x'
replace pensycounter = sum (counter) if age==`x'
if (pensycounter >= numpensy2 ) continue, break
}
}
Here is a description of the code step by step:
1 - Create age loop from 45 to 80
2 - Condition to keep going until false: while pensycounter is smaller than numpensy2 keep running the following code.
3 - If PY100G (pension value) falls within the specified interval set pensy_ss as 1
4 - Increase my local by 1 every run.
5 - Expand my interval by `x' each way
6 - Check the sum of the REAL number of individuals represented by each pensy_ss at a given age.
7 - If condition is met get out of loop and go to next age.
It's a little confusing but I hope you can understand it.
When I run the loop literally nothing happens. No error, nothing....but also doesn't do anything else. Anyone has any experience with this type of work that they can share with me? It would be most appreciated.
Best,
Luis Manso
Comment