Can you help me with the following.
I have collected the age (d4) for all the respondent. But for my analysis I want the age when they received the grant. The variable grant* are the grants for different years starting from 2006 to 2020. So for example grant1 is 2006 grant2 is 2007 grant3 is 2008 ......grant15 is 2020. Can you let me know how I can compute the age of the person when they received the grant. For example the age of the person is 20 (2021 he is 20 years old) now if grant15 is Yes then his age when he received the grant would be 19. So I want a new variable for age which is the age when the person received the grant.
Please le me know how i can do that
Please find below an example of my dataset
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(d4 grant1 grant2 grant3 grant4 grant5 grant6 grant7 grant8 grant9 grant10 grant11 grant12 grant13 grant14 grant15) 32 . . . . . . . . . . . . . 2 1 37 . . . . . . . . . . 2 2 2 2 1 26 . . . . . . . . . . . . . . 1 26 . 1 2 2 2 2 2 2 2 2 2 2 2 2 2 43 . . . . . . . . . . 2 2 2 2 1 80 . 1 2 2 2 2 2 2 2 2 2 2 2 2 2 49 . . . . . . . 2 2 2 2 2 2 2 1 68 . . . . 2 2 2 2 2 2 2 2 2 2 1 44 . . . . . . . . . . 2 2 2 2 1 34 . . . . . . . . . . 1 2 2 2 2 31 . . . 2 2 2 2 2 2 2 1 2 2 2 2 37 . . . . . 2 2 2 2 2 2 2 2 2 1 31 . . . . . . . . . 2 2 2 1 2 2 41 . 2 2 2 2 2 2 2 2 2 2 1 2 2 2 28 . . . . . . . . . . . 2 1 1 2 49 . . . . . . . . . . . . 2 2 2 49 . . . . . . . . . . . . 1 2 2 30 . . . . . . . . . . . . . 2 1 39 . . . . . . . . . . . . . . 1 30 . . . . . . . . . . 1 2 2 2 2 32 . . . . . . . . 2 2 1 2 2 2 2 40 . . . . . . . . . . . . 2 1 2 37 . . . . . . . . . . 1 2 2 . . 24 . . . . . . . . . . . . 2 2 1 22 . . . . . . . . . . . . 1 2 . 41 . . . . . . 1 2 2 2 2 2 2 2 2 63 . . . . . . . . . . . . 1 2 2 45 . . . . . . . . . 2 1 2 2 2 2 81 . . . . . . . . 1 2 2 2 2 2 . 34 . . . . . . . . . . 1 2 2 2 2 32 . . . . . . . . . . . . 2 1 2 46 . . . . . . 1 2 2 2 2 2 2 2 2 31 . . . . . . . . . . . . 2 2 1 26 . . . . . . 1 2 2 2 2 2 . . . 42 . . . . . . . . . . . 2 2 2 1 30 . . . . 1 2 2 2 2 2 2 2 2 2 2 34 . . . . 2 2 2 2 2 2 2 2 1 2 2 35 . . . . . . . . . . . . . 1 2 31 . . . . . . . . . . . 1 2 2 . 35 . . . . . . . . . . . . . 2 1 31 . . . . . . . . . . . 2 1 2 2 69 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 39 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 50 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 29 . . . . . . . . . . . . . . 1 48 . . . . . . . . . . 1 2 2 2 2 41 . . . . . . . . . . . . 1 2 2 46 . . . . . . . . . . . . . 2 1 49 . . . . . . . . . . . . 1 2 2 50 . . . . . . . 1 2 2 2 2 2 2 2 64 . . . . . . . 1 2 2 2 2 2 2 2 46 . . . . . . . . . . . . 2 2 1 31 . . . . . . . . . . 1 2 2 2 2 36 . . . . . . . . . . . . 2 2 1 49 . . . . . . . . . 2 1 2 2 2 . 32 . . . . . . . . . . 2 1 2 2 . 31 . . . . . . . . . . . 2 1 2 2 28 . . . . . . . . . . . . . . 1 28 . . . . . . . . . . . . . 1 2 35 . . . . . . . . . . . . . . 1 30 . . . . . . . . . . . . . . 1 53 . . . . . . . 2 2 2 2 2 2 2 1 34 . . . . . . . . . . . . . . 1 40 . . . . . . . . . . . . 1 2 2 56 . . . . . 2 2 2 2 2 2 2 2 2 1 41 . . . . . . . . . . . 1 2 2 . 59 . . . . . . . . . 2 1 2 2 2 . 55 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 54 . . . . . . . . . . 1 2 2 2 2 30 . . . . . . . . . . . 2 2 2 1 35 . . . . . . . . . . . . 2 1 2 42 . . . . . . . . . . 2 2 2 2 1 36 . . . . . . . . . . . 2 2 2 1 36 . . . . . . . . . . . . . 2 1 22 . . . . . . . . . . . . . . 1 32 . . . . . . . . . . . . . . 1 36 . . . . . . . . . . . 2 2 1 2 34 . . . . . . . . . . . . 2 1 2 42 . . . . . . . . . . . . . 1 2 29 . . . . . . . . . . . . 2 2 1 30 . . . . . . . . . . . . 2 2 1 63 . . . . . . . . . . . . . . 1 37 . . . . . . . . . . . 2 2 1 2 30 . . . . . . . . . . 2 2 2 2 1 24 . . . . . . . . . . . . . 2 1 36 . . . . 2 2 2 2 2 2 2 2 2 2 1 21 . . . . . . . . . . . . . . 1 29 . . . . . . . . . . . . 2 2 1 32 . . . . . . . . . . . . 2 2 1 43 . . . . . . . . . . . . . 1 2 37 . . . . . . . . . . 1 2 2 2 2 39 . . . . . . . . . . . 2 2 2 1 26 . . . . . . . . . . . . . 2 1 37 . . . . . . . . . . . 2 1 2 2 45 . . . . . . . . . . 2 2 1 2 2 31 . . . . . . . . . . . . 2 2 1 29 . . . . . . . . . . . . 2 1 2 26 . . . . . . . 1 2 2 2 2 2 2 2 30 . . . . . . . . 2 2 2 2 2 2 1 48 . . . . . . . . . . . 2 2 2 1 end label values grant1 grant label values grant2 grant label values grant3 grant label values grant4 grant label values grant5 grant label values grant6 grant label values grant7 grant label values grant8 grant label values grant9 grant label values grant10 grant label values grant11 grant label values grant12 grant label values grant13 grant label values grant14 grant label values grant15 grant label def grant 2 "No", modify label def grant 1 "Yes", modify
Listed 100 out of 147 observations
Use the count() option to list more
Thank you in advance
0 Response to Calculate the age when the grant was received from the current age and the year when the grant was received
Post a Comment