Announcement

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

  • Beginners question: Counting observations

    Hello together,

    I imported an MS Excel file into Stata and already run into issues. I used "encode" to convert the variable into "long" storage type. The variable has 239 different characteristics. For example the value 1 is assigned to the characteristis "a", 2 to "b" etc.

    My problem is now, that i want to list minimum, maximum and median numbers. However Stata will present me when using "sum" with a minimum of 1 and a maximum of 239, median is 120, which is just a categorial number but does not have any real information on how often "a" as such appears in a company or so.

    I hope that was understandable, unfortunately English is neither my first or second language!

    Thanks for the help!

  • #2
    Using encode means that your variable was entered as string with values like "a", "b", etc. The numerical representation "a" -> 1, "b" -> 2, etc. is essentially a matter of convenience for those Stata commands that don't work with string variables.

    That aside, what you want are the frequencies of your categorical variable, which you can get from the string version too. tabulate will do this; note particularly the sort option.

    summarize, if that is what you used, is not useful to you.

    (Telling us exactly what commands you used never hurts.)

    Comment


    • #3
      Yes, i used encode because i use this variable to distinguish during my regression and other parts, therefore i needed numbers that i can use in my commands. "sort" helps in some way, as i now can see how often a special characteristic appeared.

      The variable lists form of ilnesses of employees per company. So e.g. 1 is: flue, 2 is: cold etc. I have however a variable that lists all companies in numbers, so i can distuingish towards companies.

      I now want to see what the minimum amount of different diseases is, the median and the maximum. Furthermore I want to see this per company, but as I said this will not work when the variable is numerically represented.... I am a bit helpless

      Comment


      • #4
        I now want to see what the minimum amount of different diseases is
        Maybe Vanter Birad wants something related to:

        http://www.statalist.org/forums/foru...other-variable
        Last edited by Roberto Ferrer; 10 Apr 2014, 12:54.
        You should:

        1. Read the FAQ carefully.

        2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

        3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

        4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

        Comment


        • #5
          Originally posted by Roberto Ferrer View Post

          Maybe Vanter Birad wants something related to:

          http://www.statalist.org/forums/foru...other-variable
          I tried this but unfortunately does not work...

          Comment


          • #6
            I stand corrected: changing the varlist helped and gave me perfect results using egen command!! Thanks!! (still have no idea what it does, but whatever )
            Last edited by Vanter Birad; 11 Apr 2014, 09:08.

            Comment

            Working...
            X