Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72771

_n with special conditions?

$
0
0
Hi everyone,
I hope someone can help me out with this. I want to create a new variable (new_var) that counts the number of observations within each id. If dates are less than 14 days apart they should be treated as the same occasion.

My data looks like this:
id yr date between new_var
1 11 29nov2013 . 1
1 11 30nov2011 1 1
1 12 13feb2012 76 2
1 13 2jan2013 323 3
2 14 4mar2014 . 1
2 14 8mar2014 4 1

Thanks in advance!

Viewing all articles
Browse latest Browse all 72771

Trending Articles