Can someone explain the last two commands: I understand that r(max) or r(min) is to be used after the summarize command, but what operation is being performed here?
bysort id: gen subid = _n
order id subid
bysort id: egen count_event_days = count(event_window_day)
bysort id: gen max_days_in_window = count_event_days if subid==1
tab max_days_in_window
quietly sum count_event_days
keep if count_event_days==r(max)
Related Posts with keep if(varname) ==r(max)
combining dates in 2 different columnsDear Stata forum members, I need advise on how to combine dates in 2 different columns in to one co…
Should we test anticipation effect for Diff-in-Diff in natural event?Normally, the anticipation effect is tested as an assumption for Diff-in-Diff. However, it seems tha…
Selecting values from panel dataI have data on visits to a clinic. In the example below, "value date" is the date of the clinic visi…
Westerlund ECM panel cointegrationGood morning, I would like to apply a Westerlund and Edgerton (2007) panel bootstrap cointegration t…
Reverse CommandI am trying to reverse the order of some categorical variables in my dataset. There was previously a…
Subscribe to:
Post Comments (Atom)
0 Response to keep if(varname) ==r(max)
Post a Comment