SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Problem restructuring single variable into cases

    Posted Thu February 16, 2023 09:31 AM

    I am using a database on the use of a procedure, specifically, this one here titled 'detailed civil data': https://www.gov.uk/government/statistics/legal-aid-statistics-july-to-september-2022. There are 534 rows of cases that I'm interested in. However, each case does not represent an actual individual, but rather the type of issue. The number of individuals in the procedure is instead represented by a 'VOL' variable. So, one case might have a volume of 1, whereas another may have 3 or 4. There are 1844 individuals within the data I'm interested in.

    I'd like to restructure the data so that there are 1844 cases, each one representing a different individual/respondent. Unfortunately, I'm struggling to understand how to use the Restructure tool on SPSS. I'm finding that the number of rows is staying the same (at 534), or sometimes doubles to 1068. Is there a specific way on SPSS to do this, or is it not possible? Thank you :).



    ------------------------------
    Rachael B
    ------------------------------


  • 2.  RE: Problem restructuring single variable into cases

    Posted Thu February 16, 2023 10:49 AM

    Hi. I'm wondering if AGGREGATE <file> /BREAK=VOL /etc... might work better in this case; I'm not sure, obviously, but that will create a dataset with the number of cases equal to the number of unique values of that BREAK variable. The issue there will be what values of the other variables to use; for example, the mean of the numeric variables, the first instance in a BREAK group, etc.

    Look at the AGGREGATE command and see if that might be what you want.



    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 3.  RE: Problem restructuring single variable into cases

    Posted Fri February 17, 2023 05:45 AM
    Edited by Rachael B Fri February 17, 2023 05:46 AM

    The issue with aggregate is that it only creates 21 cases in the new dataset (based on the number of different entries under 'VOL', ranging from 1-25). I think I may just have to rewrite the dataset myself with separate cases for each individual, but thank you for your help!



    ------------------------------
    Rachael B
    ------------------------------



  • 4.  RE: Problem restructuring single variable into cases

    Posted Fri February 17, 2023 01:20 PM

    Oh, sorry. I missed the part about selecting only values 1-25 of VOL.

    SELECT IF RANGE(VOL,1,25).

    EXECUTE.

    should get just the VOL records you want to keep. If I downloaded and imported the same dataset you did, running the above SELECT IF still leaves me with 249,000+ cases, so there must be some other restrictions you need; those can most likely all be accommodated in a SELECT IF statement. From there, you/we can figure out how to re-structure the data to give you what you want.



    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 5.  RE: Problem restructuring single variable into cases

    Posted Fri February 17, 2023 05:47 AM

    This just comes up with reports in the Output, rather than changing the datafile itself. Thank you for your help though!



    ------------------------------
    Rachael B
    ------------------------------



  • 6.  RE: Problem restructuring single variable into cases

    Posted Thu February 16, 2023 02:06 PM
    Edited by Art Jack Tue June 13, 2023 09:35 AM

    You could also potentially do something like this.

    dataset close all.

    get file='c:\temp.sav' /keep meno email.
    CASESTOVARS
    /id=meno.



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



  • 7.  RE: Problem restructuring single variable into cases

    Posted Fri February 17, 2023 05:48 AM

    This just comes up with reports in the Output, rather than changing the datafile itself. Thank you for your help though!



    ------------------------------
    Rachael B
    ------------------------------



  • 8.  RE: Problem restructuring single variable into cases

    Posted Wed February 22, 2023 10:18 AM

    it should work.  there is also varstocases if you need the opposite. 



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