My datset includes Firms identification: NPC_FIC, Classification by broad economic categories:cgce, and fluxo=1 for import and fluxo==2 for export. I am going to compute the number of export varieties. I used the following codes though it produces the number of categories with min 1 and max 19 not the number EXPORT of goods. What I need is the number of EXPORT products of firms. As you can see the min and max in Tab cgce which are for both Export & Import. Do you know where I made mistake?
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long(NPC_FIC cgce fluxo) 500000119 2 1 502013478 17 1 502013485 6 1 502013485 16 1 501695073 17 2 500001518 6 2 500002221 6 1 501455073 10 1 502013585 16 1 502013585 16 1 500002553 10 1 502013616 10 1 502013659 10 1 500004381 10 1 500004776 13 2 502013781 13 2 502013787 12 2 501842978 4 2 500006208 10 1 500006298 17 2 500006298 16 2 500006298 16 2 502013880 17 1 500009612 13 2 500011428 13 2 500011570 6 1 500011570 6 2 500011570 6 2 500011570 6 2 500011616 17 2 500011616 16 2 500011616 16 2 500011616 16 2 500011616 16 2 500011677 6 2 502014167 10 1 501695781 6 2 500014761 6 1 502014320 16 1 500014860 10 1 500015239 6 1 500016309 16 1 500016309 10 1 500016309 16 1 500016309 16 1 500016309 15 1 500016309 17 1 500016309 10 1 500016309 10 1 500016309 10 1 500016309 10 1 500016309 6 1 500016309 10 1 500016309 11 1 502014432 5 2 502014517 11 1 502014517 11 1 502014579 10 1 500018647 6 2 500018647 6 2 500018647 6 2 500018647 6 2 500018647 6 2 500018647 6 2 500019062 6 2 500019062 6 2 500019062 6 2 500019062 17 2 500019062 17 2 500019062 10 2 500019062 6 2 500019062 15 2 500019062 6 2 500019062 9 2 502014728 6 1 502014768 17 1 502014807 18 1 500022305 5 1 500022713 17 1 500023876 18 1 501846415 12 2 501846415 17 2 501846415 17 2 501846415 17 2 501846415 5 2 500028289 6 2 500028289 6 2 501456662 10 1 501456662 17 1 500029056 17 1 500031935 6 2 500031935 10 2 500031935 16 2 500031935 16 2 500031935 10 2 500031935 16 2 500031935 6 2 500031935 6 2 500031935 16 2 500031935 17 2 end label values cgce cgce label def cgce 2 "112", modify label def cgce 4 "122", modify label def cgce 5 "21", modify label def cgce 6 "22", modify label def cgce 9 "322", modify label def cgce 10 "41", modify label def cgce 11 "42", modify label def cgce 12 "51", modify label def cgce 13 "521", modify label def cgce 15 "53", modify label def cgce 16 "61", modify label def cgce 17 "62", modify label def cgce 18 "63", modify label values fluxo fluxo label def fluxo 1 "1", modify label def fluxo 2 "2", modify ***Number of export varieties** egen tag = tag(cgce NPC_FIC) egen distinct = total(tag), by(cgce) egen n_e = count(fluxo == 2), by(NPC_FIC) ** delet duplicated **keep one firms among repeated firms** bysort NPC_FIC fluxo: keep if _n == _N & fluxo == 2 sum cgce . sum cgce Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- cgce | 22,728 10.74485 5.015334 1 19 . tab cgce COD_CGCE | Freq. Percent Cum. ------------+----------------------------------- 111 | 15,398 0.29 0.29 112 | 147,187 2.81 3.11 121 | 23,175 0.44 3.55 122 | 368,501 7.04 10.59 21 | 85,258 1.63 12.22 22 | 1,523,180 29.11 41.33 31 | 1,682 0.03 41.36 321 | 288 0.01 41.36 322 | 25,493 0.49 41.85 41 | 595,740 11.38 53.24 42 | 561,164 10.72 63.96 51 | 5,846 0.11 64.07 521 | 12,508 0.24 64.31 522 | 10,628 0.20 64.51 53 | 216,881 4.14 68.66 61 | 196,818 3.76 72.42 62 | 1,018,465 19.46 91.88 63 | 421,203 8.05 99.93 7 | 3,763 0.07 100.00 ------------+----------------------------------- Total | 5,233,178 100.00
0 Response to Number of one variable according to two other variables
Post a Comment