Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dummy for a Criminal to commit a crime again in future

    Hello everyone,
    Need help with this.
    I need to see if a person will commit a crime again after his current case has been decided. For instance, the first case filed against "A" was on 19255 and it was decided on 21259, so I need to see if there is any other case filed against "A" after the "date_of_decision" of the current case (case_1). In this case for "A", "case_21" is filed after the "date_of_decision 21259" of the current case (case_1). Looking at the current case, if a person's name comes up again with "date_of_filing" greater than the "date_of_decision" of the current case - make dummy ==1

    Need a dummy variable for this exactly like "Need_this"

    I am not sure if I am able to explain this properly so I will try some more examples:

    Dummy for person "B" is 0 because there is no case filed after the current case is decided. "date_of_filing" of "case_2" < "date_of_decision" of "case_1"

    For "I", case_1 was decided on 20770 and there was another case filed against "I" after 20770. So, this means "I" will commit a crime again in the future or there will be a case filed against "I" in the future. Notice for "I", case_2 and case_3 have dummy "0". This is because when we look at case_2, there is no case filed against "I" after case_2 (current case) has been decided.

    I would really appreciate anyone can help me with this. Please let me know if this requires more explanation. Thank you!

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str16 case_number str24 name int(date_of_filing date_of_decision) byte Need_this
    "case_1"  "A" 19255 21259 1
    "case_2"  "A" 19781 20082 1
    "case_3"  "A" 19796 20528 1
    "case_4"  "A" 19919 19931 1
    "case_5"  "A" 19974 20434 1
    "case_6"  "A" 20014 20130 1
    "case_7"  "A" 20072 21259 1
    "case_8"  "A" 20089 20472 1
    "case_9"  "A" 20353 20412 1
    "case_10" "A" 20472 20901 1
    "case_11" "A" 20474 20477 1
    "case_12" "A" 20779 20986 1
    "case_13" "A" 20849 20849 1
    "case_14" "A" 20886 21081 1
    "case_15" "A" 20915 21070 1
    "case_16" "A" 20930 20930 1
    "case_17" "A" 21012 21079 1
    "case_18" "A" 21014 21447 1
    "case_19" "A" 21059 21079 1
    "case_20" "A" 21116 21116 1
    "case_21" "A" 21296 21526 1
    "case_22" "A" 21354 21397 1
    "case_23" "A" 21372 21379 1
    "case_24" "A" 21460 21460 1
    "case_25" "A" 21536 21536 0
    "case_1"  "B" 21417 21570 0
    "case_2"  "B" 21474 21518 0
    "case_1"  "C" 20422 20434 0
    "case_1"  "D" 20171 20896 0
    "case_1"  "E" 20460 20487 0
    "case_1"  "F" 20502 20579 1
    "case_2"  "F" 21519 21519 0
    "case_1"  "G" 16204 20040 1
    "case_2"  "G" 19032 19584 1
    "case_3"  "G" 20752 20770 1
    "case_4"  "G" 21292 21296 0
    "case_1"  "H" 19288 20752 1
    "case_2"  "H" 20767 21578 0
    "case_3"  "H" 21089 21104 1
    "case_4"  "H" 21192 21225 0
    "case_1"  "I" 20770 20770 1
    "case_2"  "I" 21047 21079 0
    "case_3"  "I" 21077 21079 0
    end
    format %tddd-Mon-YY date_of_filing
    format %tddd-Mon-YY date_of_decision

  • #2
    We need to see every case for a particular name individually. If for the same person, the "date_of_filing" of a future case is greater than the "date_of_decision" of the current case, then the dummy "Need_this" for current case should be == 1.

    Comment


    • #3
      "Need_that" is a replica of "Need_this".

      Code:
      bys name: egen date_of_filing_max = max(date_of_filing)
      gen Need_that = date_of_filing_max > date_of_decision

      Comment

      Working...
      X