Hello, please, could anyone help me?
I have two data sets. The first one has data when the person committed a crime. Some individuals committed more than one crime in different dates per year.
The second dataset brings id, year when the person took a test, year, month and day when the person got ill. There are people who never got ill, people who got ill, people who never committed crime, people who committed more than one in one given year and some people who committed crimes in several years.
The data that contains test scores and illness have names repeating over the years, but not all years. so this is more like a panel at the school level.
I need to create the crime variable (y) at the individual level using the date at which they started to be ill , creating a dummy for committing any crime in one 365 days and 730 days after that. I also need to create another variable for count_crime to count the number of crimes each individual committed 365 and 730 days after being ill. Many thanks in advance!
I have two data sets. The first one has data when the person committed a crime. Some individuals committed more than one crime in different dates per year.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id yearcrime category monthcrime daycrime) 1 2000 1 3 23 1 2001 1 5 2 4 2000 2 8 5 4 2001 1 12 14 4 2002 3 1 17 5 2003 3 4 1 8 2003 2 5 6 9 2002 1 7 22 9 2003 1 9 15 28 2000 1 6 13 end
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id yeartest sick datestartedillness score) 1 2000 1 14695 100 1 2001 0 . 101 1 2002 0 . 256 2 2000 0 . 233 2 2001 0 . 99 3 2000 0 . 298 3 2001 1 15078 89 3 2002 0 . 167 4 2000 1 14945 243 5 2001 0 . 156 5 2002 0 . 128 6 2000 0 . 257 7 2000 0 . 234 7 2001 1 15226 194 7 2002 0 . 206 7 2003 0 . 108 8 2000 0 . 87 8 2001 1 15021 165 8 2002 0 . 271 9 2003 0 . 172 end format %td datestartedillness
I need to create the crime variable (y) at the individual level using the date at which they started to be ill , creating a dummy for committing any crime in one 365 days and 730 days after that. I also need to create another variable for count_crime to count the number of crimes each individual committed 365 and 730 days after being ill. Many thanks in advance!
Comment