Announcement

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

  • How to run crosstabulation with mutlple variable in the same table using APA style

    Hi Family,
    I hope this message finds you well?
    I am trying to put a cross tabulation for more than one variable together in one table and also in APA format using Stata17.
    I tried the syntax below but still not achieving the desire format;

    table (Sex) (CRS_dep), statistic(percent, across(CRS_dep)) nototals nformat(%9.2f)
    table (Education) (CRS_dep), statistic(percent, across(CRS_dep)) nototals nformat(%9.2f) append
    table (Mstatus) (CRS_dep), statistic(percent, across(CRS_dep)) nototals nformat(%9.2f) append
    table (New_AgeGrp) (CRS_dep), statistic(percent, across(CRS_dep)) nototals nformat(%9.2f) append
    table (site) (CRS_dep), statistic(percent, across(CRS_dep)) nototals nformat(%9.2f) append
    collect layout (Sex Education Mstatus New_AgeGrp site) (CRS_dep)
    asdoc collect preview

    When I open the word document, the crosstabulation came with only percentages there was no number attached eg 23(57.6%) it only provided the percentages without the number attached.


    What I want is a syntax that will generate a cross-tabulation for more than one variable that has small .'n' percentages and p-value

    Below is the sample data set;


    dataex Sex CRS_dep Education Mstatus New_AgeGrp

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double Sex float CRS_dep double(Education Mstatus New_AgeGrp)
    1 1 4 2 2
    1 2 1 2 2
    1 1 2 3 1
    1 1 2 3 2
    1 1 2 2 2
    1 1 4 3 2
    1 2 4 2 2
    1 1 2 3 1
    1 1 5 3 2
    1 1 2 2 2
    2 2 2 2 2
    1 2 4 2 2
    1 1 4 2 2
    1 2 5 3 1
    1 1 2 2 2
    end
    label values Sex Sex
    label def Sex 1 "Male", modify
    label def Sex 2 "Female", modify
    label values CRS_dep CRS_dep
    label def CRS_dep 1 "Yes", modify
    label def CRS_dep 2 "No", modify
    label values Education Education
    label def Education 1 "Tertiary", modify
    label def Education 2 "SHS", modify
    label def Education 4 "JHS", modify
    label def Education 5 "Basic", modify
    label values Mstatus Mstatus
    label def Mstatus 2 "single", modify
    label def Mstatus 3 "married", modify
    label values New_AgeGrp New_AgeGrp
    label def New_AgeGrp 1 "Above 40years", modify
    label def New_AgeGrp 2 "Below 41years", modify

    I will appreciate for your help.

  • #2
    Can you show us an example of a table that you want to create?
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Covariate Nutritional Statu p-value
      Normal(n=526) Undernutrition(n=465)
      Gender 0.045
      male 264(50.1) 263(49.9)
      female 262(56.5) 202(43.5)
      Child Age group 0.000
      0-5 83(66.9) 41(33.1)
      6-11 52(56.5) 40(43.5)
      12-23 89(43.8) 114(56.2)
      24-35 71(39.0) 111(61.0)
      36-47 98(54.1) 83(45.9)
      48-59 133(63.6) 76(36.4)
      Place of residence 0.633
      urban 188(52.1) 173(47.9)
      rural 338(53.1) 292(46.4)
      Something like this please.

      Thank you Maarten

      Comment

      Working...
      X