在car計算中,咱們獲得的結果經常是 long 縱向排列的,有時咱們也想橫向排列一下,也是能夠的,在 STATA中使用 reshape 就可以辦到。ide
clear all set more off *----- example data ----- input /// firm str7 month_year sales str3 competitor str3 competitor_location str3 competitor_branch_1 str3 competitor_branch_2 1 "1_2014" 25 "XYZ" "US" "EEE" "RRR" 1 "2_2014" 21 "XYZ" "US" "FFF" 1 "2_2014" 21 "ABC" "UK" "GGG" 21 "1_2009" 11 "LKS" "UK" "AAA" 21 "1_2009" 11 "AIS" "UK" "BBB" 21 "1_2009" 11 "AJS" "US" "CCC" 21 "2_2009" 12 "LKS" "UK" "AAA" end encode competitor, gen(comp) encode competitor_location, gen(comploc) encode competitor_branch_1, gen(compbr1) encode competitor_branch_1, gen(compbr2) gen date = ym( real(substr(month_year,3,.)), real(substr(month_year,1,1)) ) format date %tm drop competitor* month* list *----- what you want ?? ----- bysort firm: gen j = _n // this sorting is not unique reshape wide date sales comp comploc compbr1 compbr2, i(firm) j(j)
use "D:\results-0422\want01_zhuban_03day.dta", clear *若是你不想顯示那麼多變量的話,能夠提早 drop掉 不想見到的變量. bysort firm: gen j = _n reshape wide date ret mktret ar evtday, i(firm) j(j)