Hello everyone
I am facing a problem in creating a variable, called indicator, that will have a value of 1 if variable A has a value of 30 or below. Once the indicator variable assume a value of 1, it will continue to have this value for its next 9 values, irrespective of the values of variable A.
Going ahead, when the variable A has a value of 70 or above, the indicator variable will assume a value of -1 and continue to have this value for its next 9 values as well. In all other cases, the indicator variable will have a value of zero.
Consider the following example where I have manually assigned values to the indicator variable as per the above definitions.
Code:
clear
input float(A indicator)
 38.88889  0
33.283802  0
28.035044  1
31.608805  1
 28.59299  1
 28.59299  1
 35.79731  1
 34.64706  1
27.337214  1
31.631876  1
 42.26543  1
   40.046  1
 46.19867  0
   58.806  0
 39.23788  0
 42.50624  0
 45.50325  0
  45.4013  0
 42.85099  0
  45.6923  0
 50.03918  0
 48.94389  0
 68.92119  0
68.945404  0
 69.35672  0
 69.38402  0
 71.36188 -1
  74.2035 -1
  75.1806 -1
  75.1806 -1
  75.1806 -1
 78.13589 -1
 78.15923 -1
 70.61034 -1
 58.45101 -1
 57.81691 -1
 57.81691  0
 60.73603  0
  66.8223  0
 70.32132 -1
66.008896 -1
 60.47858 -1
 63.07017 -1
68.825485 -1
 69.13685 -1
 69.58298 -1
 72.04864 -1
 63.21852 -1
 55.51432 -1
 56.35549  0
 59.71494  0
 57.44476  0
 56.20992  0
 48.59141  0
 41.93623  0
  46.3338  0
 53.64366  0
 39.59586  0
 39.59586  0
33.166126  0
  26.0403  1
 29.55248  1
35.163784  1
 44.34947  1
 48.89294  1
 47.86917  1
 47.86917  1
 48.49456  1
 45.86126  1
 39.30982  1
37.153847  0
 42.23221  0
 29.79016  1
34.871796  1
34.556816  1
end