Hi everyone,
I wish to write a code that finds the maximum of the variable "difference" if the variable "negpost" is equal to 1, the minimum of the variable "difference" if the variable "negpost" is equal to -1, and just a dot if "difference" is equal to another value than -1 or 1 (see attached file for screenshot of data). This must also be done by "our_director_id" "permno1" and "event_date"
I wrote the following code, but it doesn't seem to work:
if negpost==1 {
by our_director_id permno1 event_date: egen minmax = max(difference)
}
else if negpost==-1 {
by our_director_id permno1 event_date: minmax = min(difference)
}
Would be really great if someone of you could explain me what I'm doing wrong. Thanks a lot.
Aurele
I wish to write a code that finds the maximum of the variable "difference" if the variable "negpost" is equal to 1, the minimum of the variable "difference" if the variable "negpost" is equal to -1, and just a dot if "difference" is equal to another value than -1 or 1 (see attached file for screenshot of data). This must also be done by "our_director_id" "permno1" and "event_date"
I wrote the following code, but it doesn't seem to work:
if negpost==1 {
by our_director_id permno1 event_date: egen minmax = max(difference)
}
else if negpost==-1 {
by our_director_id permno1 event_date: minmax = min(difference)
}
Would be really great if someone of you could explain me what I'm doing wrong. Thanks a lot.
Aurele
Comment