Announcement

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

  • Show number of respondents

    Hi Statalist! A quick and (likely) easy question here: I have been searching for ways to find the number of respondents (not total responses) to a "select all" question (so responses will be much higher than respondents). I am looking to figure out the # of respondents by various groups, and I came across the user-written -mdesc-, which I believe would look something like:

    Code:
    mdesc questionvar if var2 == 2 | var3 == 5
    But this gives me Missing and Total, and while I can just subtract the Missing number from the Total number to get respondents, I was wondering if there was a way to skip that step and show the number of respondents (or perhaps, in this case, just the number of non-missing) outright? Thanks much!

  • #2
    Dakota:
    an excerpt/example of your dataset provided via -dataex- can be realley helpful. Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Code:
       
       count if var2 == 2 | var3 == 5
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        As Carlo pointed out, there is no data to work on.

        That said, you may wish to fiddle with - egen -, having in sight the functions count(), rowmax(), anycount(), anyvalue(), total(), etc.
        Best regards,

        Marcos

        Comment


        • #5
          Hi all,

          Sorry for not providing a data example, I wasn't sure if it would be needed. If more context is needed: I already have code to print a table of the number of responses (in summary, I create groups based on income, and then split questionA2 and crosstab the two), but I am then hoping to get percentages of responses with the respondents as the denominator.

          So my current strategy is to get the denominator (respondents) separately and just manually calculate percentages, for example with one of the income groupings:
          Code:
          mdesc questionA2 if income == 1 | income == 2 | income == 3 | income == 4 | income == 5
          But I am hoping to, at least, get the number of respondents to show up (instead of Missing and Total and therefore having to deduce the respondents by subtracting the two).

          Thanks again so much!


          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input str12 questionA2 byte income
          ""       1
          ""       1
          ""       1
          ""       1
          ""       1
          "17"       1
          "17"       1
          ""       1
          ""       1
          "2,3"       1
          "3,4"       1
          ""       1
          ""       1
          "1,2,17" 1
          "14"     1
          "17"     1
          "17"     1
          ""       2
          ""       2
          ""       2
          ""       2
          "3"      2
          "5,17"   2
          "17"     6
          "17"     7
          ""       2
          ""       2
          ""       2
          ""       2
          ""       2
          ""       2
          ""       2
          ""       2
          ""       2
          "1"      2
          "1,17"   2
          "17"     6
          "17"     7
          "17"     8
          "2"      2
          "6"      2
          ""       3
          ""       3
          "5"       3
          "4"       3
          "4"       3
          "4"       3
          ""       3
          ""       3
          ""       3
          ""       3
          ""       3
          ""       7
          "3,5"       7
          ""       7
          ""       3
          ""       3
          ""       3
          "17"     3
          "17"     3
          "8"      3
          ""       4
          ""       4
          ""       4
          ""       4
          ""       4
          "2"       7
          "7"       4
          ""       2
          ""       6
          ""       8
          ""       9
          ""       9
          ""       9
          "2,3"       9
          ""       4
          ""       4
          end
          Last edited by Dakota McAvoy; 09 Sep 2019, 10:32.

          Comment


          • #6
            I believe a nice starting point would be a ‘well shaped’ dataset.

            By this, I mean a long (re) shape, with at least 3 variables: id, question and, say, ‘answered’.

            Indeed, the dataset above shows values as strings. What is more, several questions are under a single cell.

            Maybe this ‘plastic surgery’ would solve the issue.
            Best regards,

            Marcos

            Comment

            Working...
            X