Hello everyone, I need some help in composing a code for replacing missing values with the value of a specific year-observation. I have data structured in the following way:
id company year dum1
1 comp1 2013 1
1 comp1 2014 .
1 comp1 2015 .
1 comp1 2016 .
1 comp1 2017 .
1 comp1 2018 .
1 comp1 2019 .
2 comp2 2013 0
2 comp2 2014 .
2 comp2 2015 .
2 comp2 2016 .
2 comp2 2017 .
2 comp2 2018 .
2 comp2 2019 .
3 comp3 2013 .
3 comp3 2014 .
3 comp3 2015 .
3 comp3 2016 .
3 comp3 2017 .
3 comp3 2018 .
3 comp3 2019 .
I would like to replace missings in variable dum1 with the values of year 2013 observations so that for company 1 all subsequent years-obs. will have 1 as value, for company 2 will have 0 as value, for company 3 will have . as value.
How can I do it?
Many thanks!
Related Posts with replacing missing values with a specific year observation
Problem - Use 2 datasets in one do file (single run)Hi all ! I need help on stata I am trying to create one do file in Stata (mandatory) using 2 diff…
Panel Regression with a Moderator Variable*Please forgive my lack of Stata/Statistics knowledge or basic questions, I'm fairly new to Stata an…
Calculate number of "common friends" in the past five yearsDear fellow Statalisters, For a large panel data set on alliances, I want to calculate the number o…
Filtering quality variablesI am having s panel data on macro variables for 72 countries (I. e. ;gdp, inflation etc) and a conti…
running parmest on STATA 15Hi I was wondering if anyone could help me out a bit on the parmest command. I am using STATA 15 an…
Subscribe to:
Post Comments (Atom)
0 Response to replacing missing values with a specific year observation
Post a Comment