i have the following data for each of the 12 fama and French industries and each quarter i have a return. I would like to create a dummy variable for the extreme return per quarter which could be lowest or highest. So for each quarter when an industry has the highest or lowest return the extreme dummy variable needs to get the value 1 and 0 otherwise.
FF12 qrt returns max_return min_return
11 2011q1 -6242.417 86014.92 -6242.417
10 2011q1 -1363.764 86014.92 -6242.417
1 2011q1 -1015.994 86014.92 -6242.417
7 2011q1 1189.521 86014.92 -6242.417
2 2011q1 1588.364 86014.92 -6242.417
8 2011q1 1696.335 86014.92 -6242.417
5 2011q1 1937.876 86014.92 -6242.417
9 2011q1 3223.934 86014.92 -6242.417
6 2011q1 7801.93 86014.92 -6242.417
12 2011q1 24711.94 86014.92 -6242.417
3 2011q1 33777.23 86014.92 -6242.417
4 2011q1 86014.92 86014.92 -6242.417
11 2011q2 -11506.95 63269.62 -11506.95
10 2011q2 -1200.312 63269.62 -11506.95
1 2011q2 239.7879 63269.62 -11506.95
7 2011q2 830.6815 63269.62 -11506.95
2 2011q2 1393.649 63269.62 -11506.95
5 2011q2 1508.391 63269.62 -11506.95
8 2011q2 1987.859 63269.62 -11506.95
6 2011q2 2698.404 63269.62 -11506.95
9 2011q2 4551.7 63269.62 -11506.95
12 2011q2 19606.52 63269.62 -11506.95
3 2011q2 45043.75 63269.62 -11506.95
4 2011q2 63269.62 63269.62 -11506.95
I tried the following command
gen extreme = .
replace extreme = 1 if (returns == max_return)
replace extreme = 1 if (returns == min_return)
however then a get a variable extreme which all have the value .
FF12 qrt returns max_return min_return
11 2011q1 -6242.417 86014.92 -6242.417
10 2011q1 -1363.764 86014.92 -6242.417
1 2011q1 -1015.994 86014.92 -6242.417
7 2011q1 1189.521 86014.92 -6242.417
2 2011q1 1588.364 86014.92 -6242.417
8 2011q1 1696.335 86014.92 -6242.417
5 2011q1 1937.876 86014.92 -6242.417
9 2011q1 3223.934 86014.92 -6242.417
6 2011q1 7801.93 86014.92 -6242.417
12 2011q1 24711.94 86014.92 -6242.417
3 2011q1 33777.23 86014.92 -6242.417
4 2011q1 86014.92 86014.92 -6242.417
11 2011q2 -11506.95 63269.62 -11506.95
10 2011q2 -1200.312 63269.62 -11506.95
1 2011q2 239.7879 63269.62 -11506.95
7 2011q2 830.6815 63269.62 -11506.95
2 2011q2 1393.649 63269.62 -11506.95
5 2011q2 1508.391 63269.62 -11506.95
8 2011q2 1987.859 63269.62 -11506.95
6 2011q2 2698.404 63269.62 -11506.95
9 2011q2 4551.7 63269.62 -11506.95
12 2011q2 19606.52 63269.62 -11506.95
3 2011q2 45043.75 63269.62 -11506.95
4 2011q2 63269.62 63269.62 -11506.95
I tried the following command
gen extreme = .
replace extreme = 1 if (returns == max_return)
replace extreme = 1 if (returns == min_return)
however then a get a variable extreme which all have the value .
Comment