I have data in long format with observation year: 2000 to 2019, n=125 000.
I have a variable named “received disability benefit “ , the variable takes the value 1 the year the person received disability benefit, the other years the value will be missing. I would like to compute a new variable that takes the value of 1 if the person have received disability benefit at least one year during the observation period (2000-2019).
Is it possible to compute such variable when the data are in long format?
Many thanks,
The data look like this, example of one observation:
id | year | Received disability benefit | Received disability benefit at least one year during the observation period |
20233 | 2000 | . | 1 |
20233 | 2001 | . | 1 |
20233 | 2002 | . | 1 |
20233 | 2003 | . | 1 |
20233 | 2004 | . | 1 |
20233 | 2005 | . | 1 |
20233 | 2006 | . | 1 |
20233 | 2007 | . | 1 |
20233 | 2008 | . | 1 |
20233 | 2009 | . | 1 |
20233 | 2010 | . | 1 |
20233 | 2011 | 1 | 1 |
20233 | 2012 | 1 | 1 |
20233 | 2013 | 1 | 1 |
20233 | 2014 | 1 | 1 |
20233 | 2015 | 1 | 1 |
20233 | 2016 | 1 | 1 |
20233 | 2017 | 1 | 1 |
20233 | 2018 | 1 | 1 |
20233 | 2019 | 1 | 1 |
0 Response to long format data, creating a new variable (loop)
Post a Comment