Hello! Thank you for your help in advance.
I am using cascade replace to replace missing values with a function of the lagged value & another variable.
I have run into issues that only seem to come up when I am replacing a "large" value. Specifically (see reproducible example below), the cascade replace generates the correct answer when my initial value is <=10 million, but the wrong value when my initial value is >=20 million.
I don't know what to think, especially since 10 mil and 20 mil have the same number of digits.. Any help is appreciated
I am using cascade replace to replace missing values with a function of the lagged value & another variable.
I have run into issues that only seem to come up when I am replacing a "large" value. Specifically (see reproducible example below), the cascade replace generates the correct answer when my initial value is <=10 million, but the wrong value when my initial value is >=20 million.
Code:
* When initial value set to 20 million, doesn't work * Missing values get replaced with running_count[_n-1], whether or not third_obs=0 clear set obs 10 gen third_obs = (_n==3) gen running_count = 20000000 if _n==1 replace running_count = running_count[_n-1] +third_obs[_n] if missing(running_count) tab running_count /*shows only 1 unique value*/ * When initial value set to 10 million, does work clear set obs 10 gen third_obs = (_n==3) gen running_count = 10000000 if _n==1 replace running_count = running_count[_n-1] +third_obs[_n] if missing(running_count) tab running_count /*shows 2 unique values*/
I don't know what to think, especially since 10 mil and 20 mil have the same number of digits.. Any help is appreciated
Comment