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)
Command "do" does not work although working directory is specifiedDear Statalist Users, I am trying to run multiple do files in a row by using the command "do" (file…
Dummy variable based on 3 continuous year panel dataHi, I want to generate dummy2=1 if dummy1 is continuous (equal 1) for the 3 next years period. Any…
Unable to access elements of a local macroHi I wanted to store the unique values of a variable schoolid_2 in a local macro. So ran the follow…
Margins at() following cmxtmixlogit / cmclogit?Hi all, long time reader first time poster here. I am using StataSE 16.1 on MacOS 11.2.3. I'm analyz…
Fixed effects model - comparing the coefficients of two different regressionsDear All, I used a fixed effect regression model through the following equations to evaluate the im…
Subscribe to:
Post Comments (Atom)
0 Response to keep if(varname) ==r(max)
Post a Comment