Hey guys,

i could need some assistance with the following issue.

Dataset
Station__name Year Mean_Year Mean_till_04
Adaba 2001 70 82,5
Adaba 2002 80 82,5
Adaba 2003 130 82,5
Adaba 2004 50 82,5

I would like to create a new binary variable Climate_Shock (CS). CS is defined as CS=1 if the Mean_year of the particular year is 1sd below the Mean_till_04. So when the observation for one year is below 1sd below the long term average the new variable Climate_Shock shall give me the value 1, 0 if its not.

I have read and tried out some similair codes ( e.g.
drop if price < (r(mean) - 5 * r(sd) ) | (price> (r(mean) + 5 * r(sd)) but havent found one which works for me. Can somebody give advice how to run the code? Thanks in advance!