Announcement

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

  • Panel Data: Individual households having received tax rebate vs. number of tax rebates given

    Dear all

    This following question might be of trivial nature, but i've resorted to ask the question here as I simply cannot find the answer elsewere - and I am, admittedly, under time pressure. Should it have been debated here on the forum previously - my apologies. My frustration is somehow big, as I am sure there is a easy solution.

    As my title indicates I am currently working with panel data. My first time doing so. I have data on individual households having been interviewed once a month over a year.
    Now, each month they've answered whether they've received tax rebate payments or not, and whether they are experiencing constraints on their credit.

    I want to figure out how many households (the var "id" is an identifier for individual households) have experienced constraints or received payments during the 12 months.
    In other words, I am not interested in how many individual times the constraint-dummy is 1, but only wish to count each household once. For example, the household with id-number 5 (see picture) experienced constraints in both November and December, but i'm looking for a command to do descriptive statistics that would only count that household once. The same is the case for tax rebates - I'm interested in the number of individual households who have received such, not the amount of times it been received in total.

    Kind regards
    Attached Files
    Last edited by Mads Moring; 27 Apr 2017, 12:54.

  • #2
    This is indeed asked and answered often here.

    Code:
    by id, sort: egen ever_constrained = max(Constrained)
    by id: egen ever_got_rebate = max(Rebate > 0)
    The new variable ever_constrainedwill take on value 1 in all observations for those ids who have experienced a constraint at any point, and 0 for those ids who have never experienced a constraint. Analogously for ever_got_rebate.

    In the future please do not post screen shots to show example data. Had it been necessary to import the data to Stata to work things out, there would have been no way to do so. The helpful way to show example data is with the -dataex- command. Run -ssc install dataex- and then run -help dataex- to read the simple instructions for using it. When you use -dataex-, those who want to help you can create a replica of your Stata data example by a simple copy/paste operation And that replica will be completely faithful, so the code will approporiately take into account all the little details like data storage types, etc.


    Comment


    • #3
      Dear Mr. Schechter

      Thank you for your answer! I realised after posting that I was in violation of the guidelines of the forum, but couldn't work out how to delte the post. I also tried the dataex command, but upon posting, it looked wrong - I will look into it and try to make it right next time.

      EDIT: upon running your code, I realise that it does not work/ I dont undertand how to move on to the right table. Upon tabulating the variables It adds op to the total amounts of observations, not households. I guess I have to work out a syntax that then only count each id once?

      . bysort id ever_constrained: keep if _n==_N
      Last edited by Mads Moring; 27 Apr 2017, 14:27.

      Comment

      Working...
      X