Hi there
I am having problem with long expression due to the OR condition. I want to create a dummy variable, analyst=1, if a particular analyst is associated with an institution. In some cases, the names are the same but institution is different. As there are 800 analysts, the expression is very long as i use the following command:
by StockCode year, sort: gen analyst=1 if (AnalystName1=="Zhang Gengyun" & InstitutionCode=="BIZXZQ01" | AnalystName1=="Zhang Xiaoqing" & InstitutionCode=="BIDFZQ01")
The following is the data example
* Example generated by -dataex-. To install: ssc install dataex
clear
input long StockCode float year str10 InstitutionCode str20 AnalystName1
600036 2003 "BIZXZQ01" "Zhang Gengyun"
600422 2004 "BIDFZQ01" "Zhang Xiaoqing"
600057 2004 "BIGTJA01" "Wang Zhanqiang"
22 2004 "BIDFZQ01" "Zhang Dingjie"
542 2004 "BIGTJA01" "Wang Zhanqiang"
157 2004 "BIBHZQ01" "Wang Gang"
600020 2004 "BIJQZQ01" "Li Weiqi"
725 2003 "BIGTJA01" "Wei Xingyun"
157 2004 "BIGTJA01" "Xu Yunkai"
63 2003 "BIXJZQ01" "Pan Huanhuan"
600170 2003 "BIGTJA01" "Chen Liang"
600460 2003 "BIGTJA01" "Xiao Lijuan"
600528 2004 "BIGTJAQ1" "Chen Liang"
2031 2004 "BIGTJA01" "Xu Yunkai"
24 2003 "BILHZQ01" "Dai Lihong"
24 2003 "BIZXZQ01" "Shi Yanping"
600020 2003 "BIGTJA01" "Gao Guangxin"
Is there any short command which can save me from writing up all the 800 names and institution?
Thank you
I am having problem with long expression due to the OR condition. I want to create a dummy variable, analyst=1, if a particular analyst is associated with an institution. In some cases, the names are the same but institution is different. As there are 800 analysts, the expression is very long as i use the following command:
by StockCode year, sort: gen analyst=1 if (AnalystName1=="Zhang Gengyun" & InstitutionCode=="BIZXZQ01" | AnalystName1=="Zhang Xiaoqing" & InstitutionCode=="BIDFZQ01")
The following is the data example
* Example generated by -dataex-. To install: ssc install dataex
clear
input long StockCode float year str10 InstitutionCode str20 AnalystName1
600036 2003 "BIZXZQ01" "Zhang Gengyun"
600422 2004 "BIDFZQ01" "Zhang Xiaoqing"
600057 2004 "BIGTJA01" "Wang Zhanqiang"
22 2004 "BIDFZQ01" "Zhang Dingjie"
542 2004 "BIGTJA01" "Wang Zhanqiang"
157 2004 "BIBHZQ01" "Wang Gang"
600020 2004 "BIJQZQ01" "Li Weiqi"
725 2003 "BIGTJA01" "Wei Xingyun"
157 2004 "BIGTJA01" "Xu Yunkai"
63 2003 "BIXJZQ01" "Pan Huanhuan"
600170 2003 "BIGTJA01" "Chen Liang"
600460 2003 "BIGTJA01" "Xiao Lijuan"
600528 2004 "BIGTJAQ1" "Chen Liang"
2031 2004 "BIGTJA01" "Xu Yunkai"
24 2003 "BILHZQ01" "Dai Lihong"
24 2003 "BIZXZQ01" "Shi Yanping"
600020 2003 "BIGTJA01" "Gao Guangxin"
Is there any short command which can save me from writing up all the 800 names and institution?
Thank you
Comment