SPSS Statistics

 View Only
  • 1.  Sorting through multiple dates

    Posted Mon June 27, 2022 10:13 AM
    I have data that can have anywhere between 2-36 encounter dates, from 2018-2022. Each data entry is different and can have multiple encounters in 1 year compared to another that could only have 1 or 2 encounters for that year. I want SPSS to look at a specific time period, like 2018-2019, and then pick the earliest date of 2018 and the latest date of 2019 then subtract the two and find the time between those two dates. I later want SPSS to use the the data associated with that respective date to find the percent change during that time. Is there any way to do this? Below is an example of some of the data.


    Thanks,

    Tamer

    ------------------------------
    Tamer Elashyi
    ------------------------------

    #SPSSStatistics


  • 2.  RE: Sorting through multiple dates

    Posted Thu June 30, 2022 03:28 PM

    Hi @Tamer Elashyi,

    Looking at your example data, it seems like your encounter variables are already in chronological order.  So your task would be to loop across them, identify the two values you are interested in, and then compute the difference in time between those dates.  You don't say much about the other variables you are looking to compute a "percent change" from or how that data is organized.

    ​The IBM SPSS Statistics Command Syntax Reference Guide will likely be helpful:

    Extracting and Aggregating time 
    - https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=expressions-date-time-functions

    Conditional logic
    - https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=reference-do-if
    - https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=reference-if

    Looping and Vectors
    - https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=reference-do-repeat-end-repeat
    - https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=reference-loop-end-loop
    - https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=reference-vector

    You also might consider approaching this task via Python code-blocks in the Syntax Editor
    - https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=statistics-introduction-python-programs

    I hope this helps!



    ------------------------------
    David Dwyer
    DavidDwyerDavid
    ------------------------------