In my data set, I compare analytes analyzed in a test analyzer (X) to those analyzed in a reference analyzer (Y). In my table of descriptive statistics, I get the following for my raw data:

Code:
 tabstat T3_X T3_Y MoK_X MoK_Y LyS_X LyS_Y, stats(n mean median min max) col(stat)

    variable   |       N         mean          sd           p50       min       max
---------------+------------------------------------------------------------------------------
   T3_X        |       205     3.892098    1.421584        4.04       .19      7.56
   T3_Y        |       203     3.877951    1.412951        4.02       .22      7.43
   MoK_X       |       183     8.855191    .9536298         8.8       6.6      11.5
   MoK_Y       |       184     8.855978    .9630706         8.8       6.5      11.6
   LyS_X       |       201     1.699502    2.658693         1.4        .1      36.9
   LyS_Y       |       202     1.910693    3.848795         1.5       .11      53.7
-------------------------------------------------------------------------------------------------

What I need is that the same number of non-missing observations appears for the same analyte that is analyzed in the test (X) and the reference (Y) analyzer. I thought that adding “casewise” to the previous syntax would generate statistics of interest, but I got the following result (check the N):

Code:
 tabstat T3_X T3_Y MoK_X MoK_Y LyS_X LyS_Y, casewise stats(n mean median min max) col(stat)

    variable   |       N         mean          sd         p50        min       max
---------------+------------------------------------------------------------------------------
   T3_X        |       182     4.174835     1.14546      4.17       1.75       7.56
   T3_Y        |       182     4.159176     1.14005      4.14       1.88       7.43
   MoK_X       |       182     8.853846    .9560864       8.8        6.6       11.5
   MoK_Y       |       182     8.843956    .9524274       8.8        6.5       11.6
   LyS_X       |       182     1.782967    2.768706      1.45         .2       36.9
   LyS_Y       |       182     1.958846    3.996711       1.5         .2       53.7
-------------------------------------------------------------------------------------------------

To get what I really want, I must write a syntax for each variables of interest:

Code:
tabstat T3_X T3_Y, casewise stats(n mean median min max) col(stat)
tabstat MoK_X MoK_Y, casewise stats(n mean median min max) col(stat)
tabstat LyS_X LyS_Y, casewise stats(n mean median min max) col(stat)
This is, however, not practical when I have about 50 analytes in my data set. What kind of syntax or code/loop can I have to get statistics for analytes with the same number of non-missing observations (as seen in the table below)?

Code:
 tabstat ???????

    variable   |       N         mean          sd           p50       min       max
---------------+------------------------------------------------------------------------------
   T3_X        |       203     3.891238    1.221584        4.01       .21      7.36
   T3_Y        |       203     3.875551    1.362951        4.03       .22      7.33
   MoK_X       |       183     8.877191    .8136298         8.7       6.5      11.3
   MoK_Y       |       183     8.858778    .8530706         8.7       6.2      11.5
   LyS_X       |       201     1.699482    2.635693         1.3        .3      36.8
   LyS_Y       |       201     1.910363    3.718795         1.2       .31      53.7
-------------------------------------------------------------------------------------------------