Announcement

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

  • Explanation of a Question

    Hi,

    I am a new STATA user and I am trying to learn as much as I can by working through problem sets a friend gave me. Can you please explain what this question is asking:

    "Create a variable named sexn that is the number of respondents of a given sex. For

    example, if sex = Male, sexn should equal 590"

  • #2
    Well, in the absence of more contextual information, the best I can do is conjecture.

    I conjecture that the problem includes some data set with observations about people. Among the variables in the data set is one called sex, which takes on two values, Male and Female (and, if it is a recent data set, perhaps more). You are asked to create a new variable whose value, in any observation that has sex == "Male" will equal the total number of observations in the data set where sex == "Male". And in any observation that has sex == "Female" will equal the total number of observations in the data set where sex == "Female". (If the sex variable has other values, then the variable you are creating should, similarly, take on a value equal to the number of observations where the sex variable has that value.

    So if the starting data set looks like this:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str6 sex
    "Male"  
    "Female"
    "Female"
    "Female"
    "Male"  
    end
    the desired output is:

    Code:
           sex   wanted  
          Male        2  
        Female        3  
        Female        3  
        Female        3  
          Male        2

    Comment


    • #3
      Let me offer some general advice that I often offer to members who indicate they are new to Stata and trying to learn.

      When I began using Stata in a serious way, I started - as others here did - by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. All of these manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through Stata's Help menu. The objective in doing this was not so much to master Stata as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and manual.

      Stata supplies exceptionally good documentation that amply repays the time spent studying it - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.

      Comment

      Working...
      X