Announcement

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

  • Tab across countries with dummy variables!

    Hello all! I am a new stata user and am having trouble with coding for a question assigned by my teacher. We are using the comprehensive.dta ( Standardized Data 2002-2005)

    The question is as follows:

    Use the two-country sample of Pakistan2002 and Germany2005. (Hint: In your “keep” line, you will use “|”.) Create a dummy variable for firms that believe “electricity” is a “major” or “very severe” obstacle (c218b). Tabulate this dummy variable across countries. Report the number of observations in each country and their respective means. Interpret in words what the mean difference is telling you.

    I understand that the code starts off as:
    use comprehensive, clear
    tab country
    keep if country== "Germany2005" | country== "Pakistan2002"
    and how to generate dummy variable DVc218b:
    gen DVc218b=.
    replace DVc218b=1 if c218b==3 | c218b==4
    replace DVc218b=0 if c218b==0 | c218b==1 | c218b==2
    However, I don't understand how I tab this DV across countries (only one variable!) and the number of observations in each country and their respective means (doesn't the data form a two country sample??)

    Any help would be much appreciated. Thank you so much for your help!

    Julia
    Last edited by Julia Huang; 29 Oct 2015, 08:20.

  • #2
    Code:
    tab country DVc218b
    should give you a 2 x 2 table. Your keep statement threw out all but two countries. Your indicator (dummy) variable has values 0 and 1. By default missings won't appear in the table.

    Comment


    • #3
      Thank you for your fast reply! That did give me a 2 x 2 table. Now, how do I perform a ttest (since I am also to find the mean difference between the two countries) or is there another way to get the mean for the two countries?

      Sorry, these may be very basic questions. I just started with stata Thanks for your help in advance!

      Comment


      • #4
        Code:
         
        help ttest

        Comment


        • #5
          it states for one-sample t test, the code is

          ttest varname == # [if] [in] [, level(#)
          would the code be

          ttest DVc218b == # in, level (95)
          Still confused, thanks for the help!

          Comment


          • #6
            I think it's part of the assignment to work out what you should be doing here.

            Comment

            Working...
            X