Announcement

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

  • Separate frequency tabs for multiple variables, but in one table

    Dear Statalist,

    I have many categorical variables called qual1, qual2, qual3, etc., that use all the same category (e.g. the values of 1 for "good", 2 for "average", 3 for "bad"). I want to get the frequency tabulation for each of them separately (i.e. not crosstabs), but I want them displayed in one table for many variables, say, eight at a time.

    For example if I do
    tab1 qual1 - qual8
    I will get the frequency figures I want, but they show up as 8 tables instead of as 1 table. By the way, I don't want the "Percent" and "Cum" columns to show up, all I want is the "Freq" column. So, I want one table with 8 columns of data, if you see what I mean.

    As an alternative I tried -tabcount- The nice thing about this is that it just gives me the frequency, and not the percent and cumulative numbers that I don't want. However, if you place more than one variable after -tabcount-, it will give you crosstabs and not the individual frequencies. So this won't work either.

    This seems like a simple question so I am surprised I couldn't figure out how to do this in stata.

    I really welcome your help on this!

    Thanks,
    Hewan

  • #2
    tabcount is from SSC. Please remember to explain where user-written programs you refer to come from.

    Also check out tabm program from the same author: it's in the tab_chi package on SSC

    and

    Ben Jann's mrtab (SJ).

    Comment


    • #3
      Code:
      program define ftab
      syntax varlist
      display "`varlist'"
      forval x=0/4 {
        foreach v in `varlist' {
          quietly count if `v'==`x'
          display %8.0f r(N) " "_continue
        }
        display
      }
      end

      Comment


      • #4
        Nick and Sergiy, thanks a lot! The first option given above--tabm--does just what I want! The other options may also do the job but -tabm- is nice and simple so I'll go with that. Nick, will keep in mind to mention in the future if a command I reference came from SSC.
        Thanks,
        Hewan

        Comment


        • #5
          ... came from SSC

          ... or the Stata Journal, or a user's website or anywhere other than StataCorp.

          Comment


          • #6
            Ok Nick, noted. Thanks much.

            Comment


            • #7
              Hello,
              I am fairly new to stata and have spent a lot of time trying to create this table:
              Rows by *age of my data (6 age categories)
              Columns of different characteristics, which are responses to the survey question (*depression, *baldness, *hearing loss, etc)
              code: tab by *age variable then entering the next variable *depression will give me a table just like I want (I then have to type ==1 to only give me those who responded yes to the symptom).
              the problem is it only creates one table. i then have to repeat this many times with *age and every other variable and combine the tables in Excel.
              tabm and mrtab seem to be the best fixes.
              I am trying tabm but cannot determine how to get tabm to display each of the second characteristics (depression, etc) by age. currently, tabm only shows whether or not there was a yes respondent and dumps all yes responses into the under 18 age category, all no response in the 19-25 category, and leaves blank all of the remaining age groups.
              current code:
              tabm *age *depress *bald *hear
              That is the code that does not finish what I need.
              Can someone help me?
              Thank you!

              Comment


              • #8
                tabm is just a wrapper for tabulate. It will do what tabulate does and no more, but it supports by: What you want may be closer to

                Code:
                by age: tabm depress bald hear
                groups from SSC may also help.

                Reminders from FAQ Advice you were asked to read

                Full real names please (given name, family name)

                Explain where user-written programs you refer to come from.
                Last edited by Nick Cox; 31 Jan 2015, 03:18.

                Comment


                • #9
                  Hi statalist, pls wat command can i use to Convert numberic cartegorical variable to string cartegorical variable e.g years spent

                  Comment


                  • #10
                    Abdullahi: Please start a new thread and give more detail in your question. See http://www.statalist.org/forums/help#stata for advice.

                    Comment


                    • #11
                      Dear statalist, can you suggest me what command I should use to get the frequency for multiple variables, for example, var1, var2 and var3. I have 5 variables. all are dummy constructed variables. I want to check the possible combination of these variables, like the twoway format as follows (picture). inseated of just two var, can I use 5 variable. if so, how can i do it. please help me.

                      Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	18.1 KB
ID:	1472991


                      Comment


                      • #12
                        see -contract- and -groups- (from SSC)

                        Comment


                        • #13
                          Andrea Discacciati Thanks for the mention of groups. The source is to be regarded as the Stata Journal:

                          SJ-18-1 st0496_1 . . . . . . . . . . . . . . . . . Software update for groups
                          (help groups if installed) . . . . . . . . . . . . . . . . N. J. Cox
                          Q1/18 SJ 18(1):291
                          groups exited with an error message if weights were specified;
                          this has been corrected

                          SJ-17-3 st0496 . . . . . Speaking Stata: Tables as lists: The groups command
                          (help groups if installed) . . . . . . . . . . . . . . . . N. J. Cox
                          Q3/17 SJ 17(3):760--773
                          presents command for listing group frequencies and percents and
                          cumulations thereof; for various subsetting and ordering by
                          frequencies, percents, and so on; for reordering of columns;
                          and for saving tabulated data to new datasets

                          Hence

                          Code:
                          search st0496_1
                          takes people to the latest download location.

                          https://www.statalist.org/forums/for...updated-on-ssc gives an overview, especially for those without access as yet to the 2017 paper.

                          Comment


                          • #14
                            Andrea Discacciati and Nick Cox, thank you very much!!!

                            Comment


                            • #15
                              Dear Statalist!,

                              Can I have a qualitative dependent variable in the Oaxaca-Blinder decomposition model? For example, Instead of keeping the amount of particular variable like wage, is it possible to keep "access to the job" as a dependent variable.

                              Comment

                              Working...
                              X