Announcement

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

  • Formatting a Table

    Hi all,

    Feels like a stupid question but I can't seem to find the answer anywhere. I'm trying to layout my table like Figure 1 but the closest I'm getting is Figure 2.

    Figure 1:
    Click image for larger version

Name:	Screenshot 2022-02-15 at 16.55.26.png
Views:	1
Size:	52.8 KB
ID:	1650219


    Figure 2:
    Click image for larger version

Name:	Screenshot 2022-02-15 at 16.56.15.png
Views:	1
Size:	64.5 KB
ID:	1650220


    Thanks,
    Alex

  • #2
    you don't show either your data or your command line which makes anything a guess; you probably want to add the "nformat" option to your table command; before replying, please read the FAQ and follow its advice

    Comment


    • #3
      Sorry my mistake, the command line I've been using is:

      Code:
      table () agegrp4, stat(mean hh_b04 age_months female HAZ WAZ WHZ BMIZ Stunted BMI TLU) stat(sd hh_b04 age_months female HAZ WAZ WHZ BMIZ Stunted BMI TLU) nototals stat(frequency)
      And the data looks like this:

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str16 y2_hhid byte indidy2 int agegrp4 float(age_months female BMI HAZ WAZ WHZ BMIZ TLU Stunted) int hh_b04
      "0101014002017101"  3 4  . 0         .          .          .          .  .  4.03 0 27
      "0101014002017101"  4 4  . 0   19.8767          .          .          .  .  4.03 0 20
      "0101014002017101"  5 2  . 1         .          .          .          .  .  4.03 0  8
      "0101014002028401"  1 4  . 0 18.596388          .          .          .  .     0 0 38
      "0101014002028401"  2 4  . 1  19.60045          .          .          .  .     0 0 22
      "0101014002028401"  3 1 53 1   13.0763  -3.182385 -3.3467946  -2.013371 -2     0 1  4
      "0101014002028401"  4 1  2 1  19.45087          . -2.2728696          .  .     0 0  0
      "0101014002029701"  1 4  . 0  24.46183          .          .          .  .     0 0 52
      "0101014002029701"  2 4  . 1 20.385675          .          .          .  .     0 0 46
      "0101014002029701"  3 4  . 1         .          .          .          .  .     0 0 28
      "0101014002029701"  4 3  . 0 15.833624  -.9300151          .          . -1     0 1 15
      "0101014002029701"  5 3  . 0  17.55445 -1.1404072          .          .  0     0 1 12
      "0101014002029701"  6 3  . 1 14.762463  .27571917  -.5389342          .  0     0 1 10
      "0101014002029701"  7 2  . 0 14.318346 -1.0658615  -1.288136  -.8329981  0     0 1  7
      "0101014002029701"  8 1 36 0 15.243074 -3.9611254  -2.929939  -.8798007  0     0 1  2
      "0101014002029701"  9 1  . 1  15.06671          .          . -.10298064  .     0 0  5
      "0101014002029701" 10 3  . 1  19.31186 -1.3708225          .          .  0     0 1 18
      "0101014002040901"  1 4  . 0  21.76319          .          .          .  .    .1 0 32
      "0101014002040901"  2 4  . 1 19.047316          .          .          .  .    .1 0 27
      "0101014002040901"  3 2  . 0 13.464894 -2.7558484  -3.240099  -1.493412 -1    .1 1  8
      "0101014002040901"  4 1 49 0 14.567915  .21539055  -.2475921 -.56779593  0    .1 1  4
      "0101014002040901"  5 3  . 1  14.01602 -1.1312609  -1.730554          . -1    .1 1 10
      "0101014002040901"  6 1  7 0  20.15621 -2.8393774  -.3336747          .  .    .1 1  0
      "0101014002047101"  1 4  . 1 18.905313          .          .          .  .     0 0 52
      "0101014002047101"  2 4  . 1  24.92243          .          .          .  .     0 0 33
      "0101014002047101"  3 2  . 1  14.63203  -.8991527 -1.1203161          .  0     0 1  9
      "0101014002047101"  4 2  . 1 13.271356 -1.0400057 -1.6459676 -1.6006824 -1     0 1  6
      "0101014002047101"  5 1 18 1  12.04775   .6171415  -1.851685 -3.2462654  .     0 1  1
      "0101014002055101"  1 4  . 0 19.267614          .          .          .  .   .26 0 32
      "0101014002055101"  2 4  . 1 16.754963          .          .          .  .   .26 0 23
      "0101014002055101"  3 1 62 1 12.993896  -.4839474 -1.4572287 -1.7958477 -2   .26 1  5
      "0101014002055101"  4 1 35 1  13.82979  -2.139699 -2.2991774 -1.4885724 -1   .26 1  2
      "0101014002055101"  5 1 10 1 14.693877  -.6005127  -1.357494  -1.621124  .   .26 1  0
      "0101014002076201"  2 4  . 1         .          .          .          .  .    .5 0 50
      "0101014002076201"  3 3  . 0  15.33506 -2.3414035          .          . -2    .5 1 16
      "0101014002076201"  4 3  . 0 15.319025  -2.714551          .          . -2    .5 1 16
      "0101014002076201"  5 2  . 0  14.90443 -1.1672798  -.9550254   -.302771  0    .5 1  6
      "0102003003000401"  1 4  . 0 19.433014          .          .          .  .     0 0 42
      "0102003003000401"  2 4  . 1  22.93444          .          .          .  .     0 0 41
      "0102003003002201"  1 4  . 0 23.062723          .          .          .  .  4.54 0 48
      "0102003003002201"  2 4  . 1  32.77065          .          .          .  .  4.54 0 35
      "0102003003002201"  3 3  . 0  22.12926 -1.3178704          .          .  0  4.54 1 18
      "0102003003002201"  4 3  . 1         .          .          .          .  .  4.54 0 17
      "0102003003002201"  5 3  . 0  23.06391 -1.0545362          .          .  0  4.54 1 17
      "0102003003002201"  6 3  . 0         .          .          .          .  .  4.54 0 12
      "0102003003002201"  7 2  . 1 15.680737  -.8799683  -.3828434 .004462395  0  4.54 1  7
      "0102003003002201"  8 3  . 0 20.814007 -1.6347896          .          .  0  4.54 1 13
      "0102003003002201"  9 2  . 1 15.780687 -.11167742   .1206359          .  0  4.54 1  7
      "0102003003002201" 10 1 35 0         .          .          .          .  .  4.54 0  2
      "0102003003002201" 11 1 14 0   21.8434          .    -.64902   2.532406  .  4.54 0  1
      "0102003003017401"  1 4  . 0  22.92145          .          .          .  . 21.02 0 37
      "0102003003017401"  2 4  . 1  28.72463          .          .          .  . 21.02 0 34
      "0102003003017401"  3 3  . 0 19.271925  -.9985979          .          .  0 21.02 1 14
      "0102003003017401"  4 3  . 0 16.988062  -2.410552          .          .  0 21.02 1 12
      "0102003003017401"  5 2  . 1 14.904516  -1.355028 -1.1389387  -.6006407  0 21.02 1  8
      "0102003003017401"  6 1 55 1 16.154745 -2.1274297  -.9305239   .5891242  0 21.02 1  4
      "0102003003017401"  7 3  . 0 20.335844 -2.3779593          .          .  0 21.02 1 15
      "0102003003020001"  1 4  . 0  21.48254          .          .          .  .     2 0 33
      "0102003003020001"  2 4  . 1 19.951626          .          .          .  .     2 0 25
      "0102003003020001"  3 2  . 1         .          .          .          .  .     2 0  8
      "0102003003020001"  4 1 63 1 13.332026 -1.9934036 -2.3464544 -1.4825288 -1     2 1  5
      "0102003003020001"  5 1 37 1 16.678745  -1.412016  -.2455821   .7405677  0     2 1  3
      "0102003003020001"  6 1  1 1      15.2 -1.8867936  -.7013431          .  .     2 1  0
      "0102003003043001"  1 4  . 0  23.69649          .          .          .  .   7.3 0 33
      "0102003003043001"  2 4  . 1 20.133123          .          .          .  .   7.3 0 32
      "0102003003043001"  3 2  . 0  14.14162   -2.87187  -3.007639  -.9628684 -1   7.3 1  9
      "0102003003043001"  4 2  . 1 15.096177  -1.794601  -1.248201 -.22617672  0   7.3 1  7
      "0102003003043001"  5 1 62 1  14.49585  -1.607569 -1.4067782  -.5235748  0   7.3 1  5
      "0102003003043001"  6 3  . 0  22.20225  -.8146909          .          .  0   7.3 1 15
      "0102003003043001"  7 3  . 0         .          .          .          .  .   7.3 0 14
      "0102003003043001"  8 1 14 0 18.778425 -2.6438885  -.4577736   .8869491  .   7.3 1  1
      "0102003003047901"  1 4  . 0  24.64226          .          .          .  .     0 0 31
      "0102003003047901"  2 4  . 1 23.334486          .          .          .  .     0 0 24
      "0102003003047901"  3 2  . 0  14.54324  -2.189278 -2.1137245  -.6428425  0     0 1  8
      "0102003003047901"  4 1 69 1         .          .          .          .  .     0 0  5
      "0102003003047901"  5 1 19 1  19.68665 -4.2655015  -.8637293  1.5671586  .     0 1  1
      "0102017003000101"  1 4  . 0 22.070503          .          .          .  .     0 0 51
      "0102017003000101"  2 4  . 1  19.97027          .          .          .  .     0 0 27
      "0102017003000101"  3 4  . 0  20.60144          .          .          .  .     0 0 21
      "0102017003000101"  4 3  . 0         .          .          .          .  .     0 0 17
      "0102017003000101"  5 3  . 1 20.990046  -1.553977          .          .  0     0 1 14
      "0102017003000101"  6 1 57 1 16.316494 -2.5010345 -1.1153476   .6764315  0     0 1  4
      "0102017003000101"  7 1 49 0 17.961876  -3.613146 -1.2447076  1.4133767  1     0 1  4
      "0102017003000101"  8 1 26 0 16.399258  -4.379007  -2.697541 -.54716283  0     0 1  2
      "0102017003000101"  9 1  3 1      18.4 -4.6568217 -1.8901362          .  .     0 1  0
      "0102017003000104"  1 4  . 0 23.574814          .          .          .  .     0 0 27
      "0102017003000104"  2 3  . 1  22.59842 -1.7642382          .          .  0     0 1 18
      "0102017003000104"  3 1  3 0 18.532188 -2.2154558  -.5158406          .  .     0 1  0
      "0102017003001701"  1 4  . 1 20.443995          .          .          .  .   .09 0 50
      "0102017003001701"  2 4  . 0 20.281994          .          .          .  .   .09 0 46
      "0102017003001701"  3 3  . 0 21.148134  -2.859869          .          .  0   .09 1 17
      "0102017003001701"  4 2  . 0 14.758913  -.9523476  -.9727467 -.50419945  0   .09 1  7
      "0102017003002201"  1 4  . 1  23.69563          .          .          .  .     0 0 38
      "0102017003002201"  2 4  . 0  22.51607          .          .          .  .     0 0 42
      "0102017003002201"  3 3  . 1         .          .          .          .  .     0 0 12
      "0102017003002201"  4 2  . 0 16.806723 -2.2564173 -1.1521207   .8489153  0     0 1  9
      "0102017003002201"  5 2  . 0  16.88892  -2.806412  -1.288136  1.1463356  0     0 1  7
      "0102017003002201"  6 1 58 1  14.83747 -4.1767516 -3.1098235  -.6115683  0     0 1  4
      "0102017003002201"  7 1 25 0  15.56066          . -4.0187197  -1.435657  0     0 0  2
      "0102017003004801"  1 4  . 0   22.6061          .          .          .  .   9.4 0 36
      end
      label values agegrp4 agegroup
      label def agegroup 1 "0–5", modify
      label def agegroup 2 "5–9", modify
      label def agegroup 3 "10–19", modify
      label def agegroup 4 "20–55", modify

      Comment

      Working...
      X