Announcement

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

  • editing tables using dtable and dbtables

    Hi everyone

    just wanted help, I was trying to do a simple table

    tabulating dm, htn, and chd by ph group using this code: dtable i.dm_b i.htn_b i.chd_b, by(ph_group, tests) factor(, statistics(fvfrequency fvpercent) test(pearson)) nformat(%9.0f frequency fvpercent )
    note: using test pearson across levels of ph_group for dm_b, htn_b, and chd_b.

    it generates this output, I try to remove the rows with 0 such as DM 0, HTN 0 and CHD 0 as they are redundant (it is more of a yes or no, hypertension - 0 no, 1-yes, however when I remove those rows using db tables i also lose the pvalue which is in line with it in the same row

    any work around to this?

    thank you!

    -Kevin
    Click image for larger version

Name:	table.jpg
Views:	2
Size:	85.8 KB
ID:	1777759
    Click image for larger version

Name:	table.jpg
Views:	2
Size:	85.8 KB
ID:	1777760


  • #2
    You can specify a particular level of a factor variable. Compare:

    Code:
    webuse lbw, clear
    dtable i.(smoke ui ht), by(low, tests) factor(, statistics(fvfrequency fvpercent) test(pearson)) nformat(%9.0f frequency fvpercent )
    dtable 1.(smoke ui ht), by(low, tests) factor(, statistics(fvfrequency fvpercent) test(pearson)) nformat(%9.0f frequency fvpercent )
    Res.:

    Code:
    . dtable i.(smoke ui ht), by(low, tests) factor(, statistics(fvfrequency fvpercent) test(pearson)) nformat(%9.0f frequency fvpercent )
    note: using test pearson across levels of low for smoke, ui, and ht.
    
    ------------------------------------------------------------------------
                                               Birthweight<2500g            
                                        0           1         Total     Test
    ------------------------------------------------------------------------
    N                              130 (68.8%) 59 (31.2%) 189 (100.0%)      
    Smoked during pregnancy                                                 
      Nonsmoker                       86 (66%)   29 (49%)    115 (61%) 0.026
      Smoker                          44 (34%)   30 (51%)     74 (39%)      
    Presence, uterine irritability                                          
      0                              116 (89%)   45 (76%)    161 (85%) 0.020
      1                               14 (11%)   14 (24%)     28 (15%)      
    Has history of hypertension                                             
      0                              125 (96%)   52 (88%)    177 (94%) 0.036
      1                                 5 (4%)    7 (12%)      12 (6%)      
    ------------------------------------------------------------------------
    
    . 
    . dtable 1.(smoke ui ht), by(low, tests) factor(, statistics(fvfrequency fvpercent) test(pearson)) nformat(%9.0f frequency fvpercent )
    note: using test pearson across levels of low for smoke, ui, and ht.
    
    ------------------------------------------------------------------------
                                               Birthweight<2500g            
                                        0           1         Total     Test
    ------------------------------------------------------------------------
    N                              130 (68.8%) 59 (31.2%) 189 (100.0%)      
    Smoked during pregnancy                                                 
      Smoker                          44 (34%)   30 (51%)     74 (39%) 0.026
    Presence, uterine irritability                                          
      1                               14 (11%)   14 (24%)     28 (15%) 0.020
    Has history of hypertension                                             
      1                                 5 (4%)    7 (12%)      12 (6%) 0.036
    ------------------------------------------------------------------------

    Comment


    • #3
      thank you very much sir! this solved my problems!

      Comment

      Working...
      X