Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • custom paired ttest table

    I am running a multi-point paired t-test that is looking at scores of teacher satisfaction in the courses they taught over a couple of months. I would like to compare these scores within the type of teacher and the type of course for each month using january as the baseline score. I would like to compare the changes in scores for jan to the other months, feb, mar etc to see if there is a significant change. My problem is that I can run this but have to manually output everything onto a table. Is there an effective way to generate an automatic table that looks like my example below?


    ----------------------- copy starting from the next line -----------------------
    Code:
    bysort teachersex topic: ttest jan== feb
    ------------------ copy up to and including the previous line ------------------





    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int id str20 teachersex str7 topic double(jan feb mar apr may)
      1 "woman" "math"    1320.28 1320.28 1276.05 1283.27   11294
      2 "woman" "math"    1283.27 1347.76 1274.62 1347.56   18807
      3 "woman" "math"    1347.56 1350.24 1329.14 1333.34   21310
      4 "woman" "math"    1333.34 1334.77 1294.95 1298.35   14308
      5 "woman" "math"    1298.35 1298.35 1276.29 1295.86   11155
      6 "woman" "math"    1295.86 1311.72 1295.14  1300.8   11913
      7 "woman" "math"     1300.8 1313.76 1287.28 1313.27   12965
      8 "woman" "math"    1313.27 1332.19 1309.72 1326.82   14112
      9 "woman" "math"    1326.82 1333.21 1311.59 1318.55   12760
     10 "woman" "math"    1318.32 1327.81 1313.33 1326.65   12057
     11 "woman" "english" 1326.65 1346.92 1325.41 1329.47   13491
     12 "woman" "english" 1329.89 1352.71 1327.41 1347.97   14450
     13 "woman" "english" 1347.97 1354.55 1336.74 1342.54   14078
     14 "woman" "english" 1342.54 1353.62 1333.84  1342.9   11640
     15 "woman" "english"  1342.9  1362.9 1339.63  1360.4   12326
     16 "woman" "english"  1360.4 1369.75 1357.28  1364.3   13090
     17 "woman" "english"  1364.3 1367.35 1354.63 1357.51   12580
     18 "woman" "english" 1357.51 1357.51 1342.75 1354.95   10980
     19 "woman" "english" 1354.92 1365.54 1350.36 1364.17   10531
     20 "woman" "english" 1364.17 1375.68  1356.2 1373.73   11498
     21 "woman" "english" 1373.73 1383.37 1364.66 1366.01   12953
     22 "woman" "english" 1366.01  1373.5 1359.34 1373.47   11188
     23 "woman" "english" 1373.47 1376.38 1348.72 1349.47   10484
     24 "woman" "english" 1349.47 1354.56 1344.48 1354.31   10130
     25 "woman" "english" 1354.31 1363.55 1350.04 1352.26   10596
     26 "woman" "english" 1352.26 1352.26 1334.26 1340.89   11583
     27 "woman" "science"  1341.1 1350.32 1332.42 1332.53   11072
     28 "woman" "science" 1332.53 1332.53 1309.98 1314.76   10755
     29 "woman" "science" 1314.76 1330.96 1313.64 1330.31   10391
     30 "woman" "science" 1330.31 1336.62 1317.51  1318.8   10752
     31 "woman" "science"  1318.8 1320.73 1304.72 1315.92   11503
     32 "woman" "science" 1315.92 1331.29 1315.92 1326.61   11537
     33 "woman" "science" 1326.61 1326.61 1293.18 1301.53   12572
     34 "woman" "science" 1301.53 1307.16 1278.44 1278.94   11122
     35 "woman" "science" 1278.94 1282.97 1253.16 1255.27   12085
     36 "woman" "science" 1255.27 1259.94 1228.33 1252.82   13659
     37 "woman" "science" 1252.82 1252.82 1215.44 1245.86   12313
     38 "woman" "science" 1245.86 1267.69 1241.71 1267.65   11308
     39 "woman" "science" 1267.65 1272.76 1252.26 1257.94   11141
     40 "woman" "science" 1257.94 1263.47 1229.65 1239.94   12253
     41 "woman" "science" 1239.94 1241.36  1214.5 1241.23   12949
     42 "woman" "science" 1241.23 1251.01 1219.74 1234.18   12940
     43 "woman" "science" 1234.18 1242.55 1234.04 1241.41    9292
     44 "woman" "science" 1241.41 1267.42 1241.41  1253.8   10918
     45 "men"   "math"     1253.8 1263.86  1253.8 1261.89   11322
     46 "men"   "math"    1261.89  1266.5  1257.6 1264.74   11141
     47 "men"   "math"    1264.74 1264.74 1228.42 1233.42   10859
     48 "men"   "math"    1233.42 1233.42 1176.78 1180.16   12290
     49 "men"   "math"    1180.16 1197.83  1171.5 1197.66   13609
     50 "men"   "math"    1197.66 1197.66 1155.35 1166.71   13974
     51 "men"   "math"    1166.71 1182.04 1166.71 1173.56   12595
     52 "men"   "math"    1173.56 1173.56 1148.64 1150.53 15435.6
     53 "men"   "math"    1150.53  1173.5 1147.18 1170.81   11262
     54 "men"   "math"    1170.81 1180.56 1142.19 1142.62   12359
     55 "men"   "english" 1142.62 1149.39 1118.74 1122.14   13463
     56 "men"   "english" 1122.14 1124.27 1081.19 1117.58 17239.5
     57 "men"   "english" 1117.58 1141.83 1117.58 1139.83   13649
     58 "men"   "english" 1139.83 1160.02 1139.83 1152.69   11140
     59 "men"   "english" 1152.69 1183.35 1150.96 1182.17   13142
     60 "men"   "english" 1182.17 1182.17 1147.83 1153.29   13334
     61 "men"   "english" 1153.29 1161.69 1136.26 1147.95   12345
     62 "men"   "english" 1147.95  1162.8 1143.83 1160.33   12808
     63 "men"   "english" 1160.33 1169.51 1137.51 1145.87   12549
     64 "men"   "english" 1145.87 1145.87 1100.19 1106.46   13861
     65 "men"   "english" 1106.46  1117.5 1091.99 1103.25 14255.9
     66 "men"   "english" 1103.25 1151.47 1103.25 1151.44   13680
     67 "men"   "english" 1151.44 1151.44 1119.29 1128.43   12668
     68 "men"   "english" 1128.43 1146.13 1126.38 1137.59   10628
     69 "men"   "english" 1137.59 1173.92 1137.59 1168.38   13496
     70 "men"   "english" 1168.38 1182.24 1160.26 1165.89   12903
     71 "men"   "science" 1165.89 1183.51 1157.73  1183.5   11020
     72 "men"   "science"  1183.5 1184.64 1167.38 1179.68    9139
     73 "men"   "science" 1179.68 1192.25  1168.9 1191.81   11096
     74 "men"   "science" 1191.81 1248.42 1191.81 1238.16   19189
     75 "men"   "science" 1238.16 1253.71 1233.39 1253.69   14868
     76 "men"   "science"  1253.7  1253.7 1234.41 1242.98   13387
     77 "men"   "science" 1242.98 1242.98 1217.47 1224.36   10126
     78 "men"   "science" 1224.36 1233.54 1208.89 1209.47   12165
     79 "men"   "science" 1209.47 1232.36 1207.38 1228.75   12036
     80 "men"   "science" 1228.75  1248.3 1228.75 1234.52   13452
     81 "men"   "science" 1234.52 1253.07 1234.52 1253.05   10913
     82 "men"   "science" 1253.05  1269.3 1243.99 1249.46   12668
     83 "men"   "science" 1249.46 1266.47 1243.55 1266.44   11813
     84 "men"   "science" 1266.44 1272.93  1257.7 1267.43   13422
     85 "men"   "science" 1267.43 1267.43 1239.88 1248.58   11379
     86 "men"   "science" 1248.58 1267.51    1232 1266.61   10821
     87 "men"   "science" 1266.61    1270 1259.19 1263.51    9490
     88 "men"   "science" 1266.71 1267.01    1253  1261.2   10063
     89 "men"   "math"     1261.2 1261.65 1247.83 1255.54   11324
     90 "men"   "math"    1255.54 1268.14 1254.56 1255.18   10567
     91 "men"   "math"    1255.18 1259.84 1240.79 1245.67    9062
     92 "men"   "math"    1245.67 1249.68 1241.02 1248.92    8582
     93 "men"   "math"    1248.92 1257.45 1245.36 1249.44   10718
     94 "men"   "math"    1249.44 1286.39 1243.02 1284.99   14053
     95 "men"   "math"    1284.99 1296.48 1282.65 1288.49   13556
     96 "men"   "math"    1288.49 1292.06 1281.15 1291.96   11308
     97 "men"   "math"    1291.96 1312.95 1287.87 1312.83   11749
     98 "men"   "math"    1312.83 1315.93 1306.89 1309.38   12604
     99 "men"   "english" 1309.38 1309.38  1288.7 1289.05   11348
    100 "men"   "english" 1289.05 1295.04 1281.22 1293.17   11007
    end
    ------------------ copy up to and including the previous line ------------------

    Variable Men Women Prefer not to answer P
    Baseline to feb, mean (SD)
    baseline to march, mean (SD)
    Baseline to apr, mean (SD)
    Baseline to may, mean (SD)

  • #2
    Which version of Stata are you using? If version 17 or later, you can use the collect suite of commands to achieve this. A good starting point is
    Code:
    help tables_intro
    and from there follow the link to the PDF documentation for [TABLES] Example 4. For the current version (Stata 19), this documentation is available online as well.

    Comment

    Working...
    X