Announcement

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

  • Issues using table1 options

    Hi, I'm using the ssc table1 command to generate a baseline characteristics table.

    My code is below

    Code:
    table1, by(diagnosed) vars(r2agey contn \ Gender cat \ Race cat \ BMI contn \ reported_health cat \
     Qualifications cat \ alcoholfreq cat \ activity_freq cat \ smokers cat )  (format(%2.1f) saving(tabl1.xls, replace)
    This works fine. However I want to add a few options to format the table, including the content 'one' option to remove the categorical labels from being in another column and the content percent option so I can only obtain the percentages and not the frequencies for my variables.

    I've searched throughout this forum and the web and cannot find how to incorporate these into my command? I've tried various ways but I always get an error.

    Thank you in advance

  • #2
    slight variations on the example in the help file work for me (e.g., adding "percent" or "one" or both to the end of the second example); you need to show us, as the FAQ requests, exactly what you typed and exactly what Stata responded with; please put these in CODE blocks (see the FAQ for how to do that)

    Comment


    • #3
      We can better help you if we know what commands you have tried and what Stata told you to indicate that there was a problem. Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. See especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using CODE delimiters, as described in section 12 of the FAQ. Note particularly

      12.1 What to say about your commands and your problem

      Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!
      ...
      Never say just that something "doesn't work" or "didn't work", but explain precisely in what sense you didn't get what you wanted.
      With that said, help table1 suggests that the onecol and percent options (if those are indeed what you want) should just be added to the end of your command. Copying your command below, suppressing the vars arguments for brevity, removing the left parenthesis incorrectly preceding the format option, and adding these two options yields a command that looks like the following.
      Code:
      table1, by(diagnosed) vars( ... ) format(%2.1f) saving(tabl1.xls, replace) onecol percent
      Added in edit: Crossed with Rich's advice; our advice is the same but his is less loquacious.

      Comment


      • #4
        Apologies! This was the code I used
        Code:
        table1, by(diagnosed) vars(r2agey contn \ Gender cat \ Race cat \ BMI contn \ reported_health cat \
        >  Qualifications cat \ alcoholfreq cat \ activity_freq cat \ smokers cat ) (content(onecol) (content(percent) (format(%2.1f) test saving(tabl1.xls, replace)

        Comment


        • #5
          And what is it that Stata told you when you used the command?

          Comment


          • #6
            well (1) that doesn't show the error message and (2) it is wrong; there is no reason for either the parenthesis or the work content in either case; just add "percent one" instead of "(content(onecol) (content(percent)"

            Comment


            • #7
              Originally posted by William Lisowski View Post
              We can better help you if we know what commands you have tried and what Stata told you to indicate that there was a problem. Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. See especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using CODE delimiters, as described in section 12 of the FAQ. Note particularly



              With that said, help table1 suggests that the onecol and percent options (if those are indeed what you want) should just be added to the end of your command. Copying your command below, suppressing the vars arguments for brevity, removing the left parenthesis incorrectly preceding the format option, and adding these two options yields a command that looks like the following.
              Code:
              table1, by(diagnosed) vars( ... ) format(%2.1f) saving(tabl1.xls, replace) onecol percent
              Added in edit: Crossed with Rich's advice; our advice is the same but his is less loquacious.
              Thanks, I tried that and it worked great

              Originally posted by William Lisowski View Post
              And what is it that Stata told you when you used the command?
              It said
              Code:
              option ( not allowed
              r(198);

              Comment


              • #8
                Is there a way to get CIs in to the table and not only p-values?

                Comment


                • #9
                  I don't think it can be done with -table1-; however, I believe that -basetable- (available from SSC) can include CI's; I'm not sure about -partchart- (SJ) but I don't think it can include CI's

                  Comment

                  Working...
                  X