SPSS Statistics

SPSS Statistics

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

 View Only
  • 1.  How to select data range

    Posted Thu November 16, 2023 09:05 PM

    Hi,

    I am seeking help in copying a range of data from a variable/column.  For example I would like to copy data from cells 1000 to 2000 only out of Var A in a file with 5000 cases.  I hope I have described this correctly!

    Thanks.



    ------------------------------
    Australian User
    ------------------------------


  • 2.  RE: How to select data range

    Posted Fri November 17, 2023 06:34 AM

    Hello there.

    You coud use something like:

    dataset copy new_data_set.
    dataset activate new_data_set.
    compute num = $casenum.
    selecf if num ge 1000 and num le 2000.
    match files
    /file = *
    /keep =
    Var_A.
    execute.

    Or:

    if $casenum ge 1000 and $casenum le 2000 Var_B = Var_A.

    Oddly, $casenum seems not to work directly with select if.



    ------------------------------
    Patrick Henry-Lucet
    ------------------------------



  • 3.  RE: How to select data range

    Posted Fri November 17, 2023 09:38 AM
    The problem with using $casenum here is that it doesn't increment if the case is not selected.

    --





  • 4.  RE: How to select data range

    Posted Thu November 30, 2023 05:33 PM

    Hi Patrick

    apologies I forgot to reply.  Thank you for the syntaxes.  I tried the first one, which did not work as intended, for some reason it deleted the last character of the whole of the column I wanted to select the data range from!

    Not being proficient in programming I then used the workaround of copying the whole column to a new dataset, and then perform a select case function.  Clunky, but I got the data I needed!

    Cheers.



    ------------------------------
    Australian User
    ------------------------------