SPSS Statistics

 View Only
  • 1.  Select and Filter by Cases Based on Frequency

    Posted 22 days ago

    Hello All, first time here.

    I want to select cases (rows) based on the frequency of a numerical value in a variable column, which are unique IDs. However, each ID may have 1 to 50 sessions, with each session listed as an individual row. 

    Variable Column: ID

    Rows: Individual sessions. 

    Essentially, I am looking for something like this, but I haven't gotten anything to work. 

    Compute if frequency of 'ID' is greater than 2 as '1' or else '0' to new variable called 'enough_sessions'. '1' would mean 'yes' enough sessions. Then,

    I would add 'enough_sessions = 1' and be able to perform other analyses on just those participant IDs with at least three sessions. 

    Any tips? Thank you!!!

    Colter



    ------------------------------
    Colter Clayton
    ------------------------------



  • 2.  RE: Select and Filter by Cases Based on Frequency

    IBM Champion
    Posted 22 days ago
    Use AGGREGATE (Data > Aggregate) breaking on id and choose count as the statistic.  Then you can select your sample using that new variable > 2 or whatever.

    --





  • 3.  RE: Select and Filter by Cases Based on Frequency
    Best Answer

    Posted 21 days ago

    i'd use addvariables in the aggregate.

    AGGREGATE OUTFILE=* mode=ADDVARIABLES /BREAK=id  /count=n.



    ------------------------------
    Art Jack
    ------------------------------



  • 4.  RE: Select and Filter by Cases Based on Frequency

    Posted 20 days ago

    This works perfectly, thank you! Also, how would I add to break with an additional variable? So, I have my 'ID' variable and I have an 'appoint_type' variable that has values from 1 to 5. If I want to break by 'ID' and 'appoint_type' when 'appoint_type' is equal to 1, how would I properly add that to the syntax? For example, 

    AGGREGATE OUTFILE=* mode=ADDVARIABLES /BREAK=id and appoint_type=1 /count=n.

    Additional syntax added in italics



    ------------------------------
    Colter
    ------------------------------



  • 5.  RE: Select and Filter by Cases Based on Frequency

    Posted 20 days ago
    Edited by Art Jack 20 days ago

    i think something simple like this would work.

    if appoint_type=1 flag=1.

    recode flag(missing=0).

    aggregate outfile =* /break id flag /count=n.

    or 

    aggregate outfile =* /break id appoint_type /count=n.

    ------------------------------
    Art Jack
    ------------------------------



  • 6.  RE: Select and Filter by Cases Based on Frequency

    Posted 9 days ago

    Thank you Art! 



    ------------------------------
    Colter Clayton
    ------------------------------



  • 7.  RE: Select and Filter by Cases Based on Frequency

    IBM Champion
    Posted 20 days ago
    You can have any number of break variables in that list (no and) but would have to create a variable for the appoint_type = 1 expression.  

    --





  • 8.  RE: Select and Filter by Cases Based on Frequency

    Posted 9 days ago

    This works perfectly, Jon. Thank you! 



    ------------------------------
    Colter Clayton
    ------------------------------