Announcement

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

  • Frequency Table

    Hi


    I am using STATA 12 IC., and quite new to it.

    1) In my Excel dataset, missing values are denoted with dot. I import the Excel dataset into STATA and create a 1- or 2-way table with it. But the table automatically include the dot as a value, and I didn't include the missing command.

    Eg of my code:

    tab variable name

    2) How do I increase the width or height of my table so values with longer names don't get truncated?

    Thank you

  • #2
    To suppress the dots you could try the following:

    Code:
    tab varname if varname!="."

    Comment


    • #3
      Hi

      This works
      tab varname if varname!="." but I don't want all the percentage & cumlative %, which appears in the my table although I didn't add ", row column cell" in my code Thanks

      Comment


      • #4
        Are you referring to a 1-way or 2-way tabulation in which you wish to suppress the percentages etc? In a 2-way tabulation you should only get frequencies by default. In a 1-way tabulation, I'm unsure how to suppress percentages in the output window. You could copy and paste the table into MS Excel and then delete the columns you don't want. Alternatively, you could use the following code to generate a list of frequencies as a data set (make sure you have saved your working data set first though!).

        Code:
        gen count = 1
        collapse (sum) count if varname!=".", by(varname)

        Creating the frequencies as a dataset will also get around the problem of truncating values in the output window.

        Comment


        • #5
          In addition to collapse that Rachael mentioned, you can also use contract. It, too, destroys the dataset, and so be sure to either save the dataset beforehand or use preserve.
          Code:
          preserve
          contract variable_name if variable_name != ".", freq(count)
          list, noobs separator(0) abbreviate(20)
          restore

          Comment


          • #6
            Hi Rachel & Joseph

            Thanks for the replies. But...

            1) Code:

            gen count = 1 collapse (sum) count if varname!=".", by(varname) What does "collapse (sum)" do?
            2) When I copy and paste the Frequency table from Stata output window to Excel, the columns are not separated into their respective columns in Excel, any way to solve this? Thanks

            Comment


            • #7
              Oh

              1) I solved 2) already by choosing "Copy Table" in Stata

              Comment


              • #8
                Another way to get frequencies without percentages is to use the table command instead of tabulate.

                You can also deal with your missing value problem by making the observations with the value "." into blanks:
                replace varname="" if varname=="."

                Since you are new to Stata, you should familiarize yourself with the documentation and how to search the help files for keywords of interest. The help files are very thorough and usually very helpful.

                Comment


                • #9
                  http://www.talkstats.com/showthread....requency-Table

                  Comment

                  Working...
                  X