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
How to recode data with multiple groupsHi Everyone, I am fairly new to stata and I am looking at cancer data. I have histology groupings f…
Proportional odd assumption for ordered logit regression in panel dataRespected sir, I am using xtologit command for ordered logit regression for panel data. My dependent…
a new variable based on two existing variablesHi, I'm using SHARE dataset where there is a dummy variable for people having played chess/cards in…
Simple loop questionDear Listers, I would like to ask you a very simple question regarding loop. I want to make a vari…
How to solve autocorrelation and hetero ?I using xtserial and xttest3 What should I do to deal with autocorrelation and hetero ? My data have…
Subscribe to:
Post Comments (Atom)
0 Response to Changing the value of many observations
Post a Comment