Hello All,
I wanted to create a new variable score1, which equals the value of the variable score when variable rank=1 within that year and region. I have been trying different ways, but no success. Here are my unsuccessful codes:
This line of codes generates missing values. For the score1, what I want to achieve is to have 0.22 for the entire year 2016 and region 1; and 0.51 for the entire 2016 and region 2. I am not a Stata savvy. I cannot figure that out. Any help is much appreciated!
Many thanks,
David
I wanted to create a new variable score1, which equals the value of the variable score when variable rank=1 within that year and region. I have been trying different ways, but no success. Here are my unsuccessful codes:
Code:
by year region, sort: gen score1 = score if rank==1
Code:
*To install: ssc install dataex clear input int year int region float score int rank 2016 1 0.22 1 2016 1 0.18 2 2016 1 0.15 3 2016 2 0.51 1 2016 2 0.42 2 2016 2 0.41 3 2015 1 0.98 1 2015 1 0.67 2 2015 1 0.17 3 2015 2 0.72 1 2015 2 0.66 2 2015 2 0.60 3 2014 1 0.59 1 2014 1 0.52 2 2014 1 0.36 3 2014 2 0.65 1 2014 2 0.60 2 2014 2 0.50 3 end
David
Comment