I'm sure there's a simple way to do this but I can't seem to find a solution.
I have two variables, one containing both the start and peak values of a signal (stored in start) and a second variable indicating where there's a pair (i.e. the start (location == 1) and the peak (location == 2) of each signal increase (sometimes there's no peak)).
I want to create a new variable to store the difference between each pair (i.e. the amplitude of the signal: peak – start for each pair and store this at location == 2 in the new variable). I'm not sure how to loop back over the missing values and unpaired 1s from the peak value at location == 2 to the start value at location == 1 for each pair. Can someone help please? :-S
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(start location) 3.7167106 1 . . 3.9673915 2 . . . . . . 3.625683 1 . . 3.852861 2 . . . . 3.636759 1 . . . . 3.811554 2 . . . . . . . . . . . . . . 3.471214 1 . . . . . . . . . . . . . . . . 3.317838 1 . . . . . . . . . . 3.26407 1 . . 3.495139 2 . . 3.29939 1 . . . . . . . . . . . . . . . . . . . . 3.233487 1 . . . . . . . . . . 3.188093 1 . . . . . . . . . . . . . . . . . . . . . . 3.0768125 1 . . . . . . . . 3.2485664 2 . . . . . . . . . . . . 3.096682 1 . . . . . . . . . . . . . . . . . .
0 Response to Calculating the difference between two paired observations ignoring missing values
Post a Comment