Announcement

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

  • help on counting with multiple criterias

    Hello, I am new to Stata hence excuse my basic questions.
    I have the following data set(example). I want to calculate the count of a particular permno for a particular value of t. Eg: how many permno "123" are there for t=1,t=2 etc separately and store it in a third column. I want to count this for all permno. Kindly help. I tried using count if but it is giving me total count.
    permno t
    123 1
    123 1
    312 1
    312 1
    123 2
    312 2
    456 2
    456 2
    123 2
    456 2
    123 3
    312 3
    312 3
    123 4
    312 4
    312 4
    312 4
    456 4
    312 5

  • #2
    Code:
    bysort t permno: gen wanted = _N

    Comment


    • #3
      Hi, Thank you for the response.
      this code does not seem to work as am getting 1 for every row(which is not the case).

      Comment


      • #4
        Sorry, the code worked now. my data had got corrupted which showed all values as 1. Thank you so much for the responce.
        Have a great day.

        Comment

        Working...
        X