Hello
So, i'm working on a pretty big dataset for a Norwegian insurance company, and I wanted to change one variable in regards to its observations, or rather what the value Stata "reads" from it. Initially the observations were string and essentially showed "Expired" for an insurance offer that was no longer valid, "rejected" for a rejected insurance offer (by the company) and "accepted" was just missing values.
I started off using "decode" which made "expired" = 1, rejected = 2 and "accepted" = "." (Just a period). I do not really need the "rejected" observations so i essentially want to make the "expired" = 0 and "accepted" = 1. The variable name is "avsluttet_aarsak" (Which loosely translates to "reason for termination/closure")
I used the code:
sort avsluttet_aarsak
replace avsluttet_aarsak = 0 in 1/762621. --> Which worked for the "expired" observations, but when i wrote:
replace avsluttet_aarsak = 1 in 76262/1500403 --> then all the "accepted" observations became "rejected".
I assume this is because the underlying value that the "rejected" observations have is 1, due to the initial decoding, and this is why that happens.
Does anyone know of an easier and better way of doing this? I'm quite new to Stata so any help/input would be much appreciated
Related Posts with Changing the value of many observations
Loop with spaces and quotesHello, I have a list of terms that have spaces and quotes that I want to loop over. I have been abl…
Instrumental variables for Stata's -reg3- in 3SLS modelsHi, I am dealing with an econometric modeling issue which is new to me. While I have used 2SLS and …
forvalues with skipped valuesI have about 300 items for which I want to run the forvalues loop. However, I need to skip about 6 v…
Dummy variables for table values for percentileHey guys, I want to create one dummy variable which assigns a value of 1 for values above 90 percen…
create a variable for the second lowest valueI have a list of values (bids). I already have generated the minimum value via: Code: egen minbid…
Subscribe to:
Post Comments (Atom)
0 Response to Changing the value of many observations
Post a Comment