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

Counting number of ID's subject to conditions

$
0
0
Dear all,

I am trying to count number of id's by years conditional on observations in a three year window prior and after an observation. In other words, i want to count how many ID's which have values in a three year lagged window OR a three year lead window when the variable "seo"==1. I have used the xtset command to set the time-series.

My code is as follows:
xtset ID year
egen countID=count(ID) if seo==1 & l3.tv_rep+l2.tv_rep+l1.tv_rep>0 & f1.tv_rep+f2.tv_rep+f3.tv_rep>0 , by(year)

However this counts only ID1s by years only if there is values in the three year lagged window AND three year lead window.

Is it a way to tell stata OR?

I hope my question is clear, and thank you in advance!

Best,
Magnus Justad

Viewing all articles
Browse latest Browse all 72758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>