SPSS Statistics

 View Only
  • 1.  Identify replicate encounters of same individuals on the same day

    Posted 2 days ago

    The rows in my data file (cases) describe encounters (enc_id, numeric) of individuals (ind_id, numeric) on the dates on which they were ecountered (enc_date, date). I want to identify repeat encounters of the same individuals on the same days. For exmple if a new variable were created such the first encounter of an individual on a given day was idenfied as 1, and all repeats identified as 2, that would be all I needed. Counting repeats in the order of enc-id would be nice but unnecessary.



    ------------------------------
    Lyndon Brooks
    ------------------------------


  • 2.  RE: Identify replicate encounters of same individuals on the same day

    Posted 2 days ago

    I might not get the question correctly, but a simple solution could be to use the routines for identifying duplicate cases. In the menus, look for Data/Identify Duplicate Cases, and use ind_id and enc_date as "break variables". After that, set the Indicator of primary cases to "First case in each group is primary". The new variable/indicator is set to 1 for the first case and 0 for the repeats, but you can if needed use the recode procedure to set 0 to 2.



    ------------------------------
    Robert Lundqvist
    ------------------------------



  • 3.  RE: Identify replicate encounters of same individuals on the same day

    Posted 2 days ago
    All of these could potentially work.

    1st.
    sort cases meno(a).
    DO IF meno <> LAG(meno) or MISSING(LAG(meno)) = 1.
        COMPUTE counter_id = 1.
    ELSE IF meno = LAG(meno).
        COMPUTE counter_id = lag(counter_id) + 1.
    END IF.
    execute.
    2nd
    AGGREGATE OUTFILE=* mode=ADDVARIABLES /BREAK=meno /count=n.
    3rd
    sort cases by meno.
    split file layered by meno.
    compute flag=$casenum.
    split file off.





  • 4.  RE: Identify replicate encounters of same individuals on the same day

    Posted 2 days ago
    Another solution: assuming that you have an id variable and the cases are sorted by it, you can just check whether the preceding case has the same id value by using the LAG function (with special provision for case number 1).


    --