Hello,

I have a dummy variable with 1 and -1: 1 corresponds to a peak, and -1 - to a trough. I want to replace the points between 1 and -1 (i.e., the recession) with 1, and all the other points with 0. That is, I'm interested only in the points between a peak (1) and the next trough (-1). Here's an example of the data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(per_q logGDP_point)
120  0
121  0
122  0
123  0
124  0
125  0
126  0
127  0
128  0
129  0
130 -1
131  0
132  0
133  0
134  0
135  0
136  0
137  1
138  0
139 -1
140  0
141  0
142  0
143  0
144  0
145  0
146  1
147  0
148  0
149  0
150  0
151  0
152  0
153  0
154  0
155  0
156  0
157 -1
158  0
159  0
160  0
161  0
162  0
163  0
164  0
165  0
166  0
167  0
168  0
169  0
170  0
171  0
172  0
173  0
174  0
175  0
176  0
177  0
178  0
179  0
180  0
181  0
182  0
183  0
184  0
185  0
186  0
187  0
188  0
189  0
190  0
191  0
192  0
193  0
194  1
195  0
196  0
197  0
198  0
199  0
200 -1
201  0
202  0
203  0
204  0
205  0
206  0
207  0
208  0
209  0
210  0
211  0
212  0
213  0
214  0
215  0
216  0
217  0
218  0
219  0
end
I would appreciate any help.