Hi,
I have a string variable '"hh_id". I am trying to identify when the observations change in this string variable by generating a new variable.
I used the following syntax:
While correctly marking the change in the observations, it is marking only for one quarter. "tag" is incompatible with "by".
The data is given below:
Any help will be greatly appreciated.
Thank you.
I have a string variable '"hh_id". I am trying to identify when the observations change in this string variable by generating a new variable.
I used the following syntax:
Code:
egen tag = tag(hh_id)
The data is given below:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str3 hh_id str2(qtr month) byte tag "ABC" "Q1" "M3" 1 "ABC" "Q1" "M1" 0 "ABC" "Q1" "M2" 0 "ACD" "Q1" "M1" 1 "ACD" "Q1" "M2" 0 "ACD" "Q1" "M3" 0 "ADF" "Q1" "M1" 1 "XYZ" "Q1" "M1" 1 "XYZ" "Q1" "M2" 0 "ABC" "Q2" "M1" 0 "ABC" "Q2" "M3" 0 "ABC" "Q2" "M2" 0 "ACD" "Q2" "M3" 0 "ACD" "Q2" "M1" 0 "ACD" "Q2" "M2" 0 "ADF" "Q2" "M1" 0 "XYZ" "Q2" "M1" 0 "XYZ" "Q2" "M2" 0 end
Thank you.
Comment