Search code examples
variablesmultiple-columnsspssmedian

Median of two variables/columns


I know that you can get Medians of two variables or columns easily in other programs, but is this possible in SPSS? So for example I have

measurement1 measurement2
1         2
1         2
1         1
2         3
5         4

and I want the median for all of these together? So my answer should be 2.


Solution

  • Like @Andy W says, this will do the job:

    *creating sample data.
    DATA LIST list/measurement1 measurement2 .
    begin data
    1         2
    1         2
    1         1
    2         3
    5         4
    end data.
    
    * data restructure.
    dataset name OrigData.
    dataset copy Long.
    dataset activate Long.
    VARSTOCASES /make val from measurement1 measurement2/index=Measurment(val).
    
    * now you can get your answer in the output window.
    frequencies ‎‪val/STATISTICS=median.
    
    * or in a separate dataset.
    DATASET DECLARE YourAnswer.
    AGGREGATE  /OUTFILE='YourAnswer'  /BREAK=  /val_median=MEDIAN(val).
    dataset activate YourAnswer.