Announcement

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

  • table 1 row categorical variable and how to omit a level

    Dear all,

    I am trying to create a customized table using the table command. The issue I am having is, my row variable which is different pathogen has 0 and 1 as a level. I want to hide the 0 and categorize the pathogen based variable that looks at whether the participants had stool sample with/without blood. I also want to add the P-Value (Pearson chi2). I would appreciate any input on how to possibly address this.
    Click image for larger version

Name:	Screen Shot 2022-11-15 at 11.52.16 AM.png
Views:	1
Size:	59.6 KB
ID:	1689556

    Last edited by Derartu Ahmed; 15 Nov 2022, 10:52.

  • #2
    You probably need to show your code and provide some data with dataex to get help.

    Comment


    • #3
      Thank you for letting me know. I am new to the community, so I appreciate the suggestion. The codes I used are below.
      I used the link pasted as reference. https://blog.stata.com/2021/06/24/cu...assic-table-1/
      Click image for larger version

Name:	1.png
Views:	1
Size:	132.9 KB
ID:	1689713

      Click image for larger version

Name:	2.png
Views:	1
Size:	188.0 KB
ID:	1689715

      Click image for larger version

Name:	3.png
Views:	1
Size:	163.6 KB
ID:	1689716

      Click image for larger version

Name:	4.png
Views:	1
Size:	59.1 KB
ID:	1689717

      Comment


      • #4
        Derartu Ahmed it would be good for you to go through the Statalist FAQ, especially section 12. Please post your code (not the output of the Results window) using CODE delimiters (use the # button on the toolbar), and also post an extract of your data using the dataex command. That is the best way to seek help, because it helps others help you.

        Comment


        • #5
          Thank you so much for the further clarification. I want to hide the 0 for the
          Code:
          pcr_bacteria___1 pcr_e_coli___1
          pcr_parasite___1
          and categorize it based on stool sample with/without blood. I also want to add the P-Value (Pearson chi2). I would appreciate any input on how to possibly address this

          Commands I used:
          Code:
          table (var) (multipath nps_neighborhoodyesno), statistic(fvfrequency pcr_bacteria___1 pcr_e_coli___1
          pcr_parasite___1) statistic(fvpercent pcr_bacteria___1 pcr_e_coli___1 pcr_parasite___1 )
          collect dims
          collect label list result, all 
          collect recode result fvfrequency = column1 fvpercent = column2
          collect label list result, all 
          collect layout (var) (multipath#nps_neighborhoodyesno#result[column1 column2])
          collect style cell var[pcr_bacteria___1 pcr_e_coli___1 pcr_parasite___1 ]#result[column1],
          nformat(%6.0fc)
          collect style cell var[pcr_bacteria___1 pcr_e_coli___1 pcr_parasite___1]#result[column2],
          nformat(%6.1f) sformat("%s%%")
          collect preview
          My data looks like this:
          Code:
          * Example generated by -dataex-
          clear
          input float multipath byte(nps_neighborhoodyesno stool_blood pcr_bacteria___1 pcr_e_coli___1 pcr_parasite___1) 010000
          010000
          010000
          01.000
          010000
          01.000
          011000
          01.000
          010000
          01.000
          01.000
          010000
          011000
          01.000
          010000
          110100
          01.000
          010000
          01.000
          110010
          110010
          01.000
          010000
          010000
          011000
          010010
          111000
          011000
          011000
          011000
           Listed 30 out of 211 observations

          Comment

          Working...
          X