Hi guys, I wanna thank you first, cause I have received so much help here. This is such a great forum! I will try my best to help others as well.
I have another question.I have a dataset of stock market index of 40 countries. And I need to generate the correlations between US and the other 39 countries.
I tried the code below,
bysort fyear: corr Australia_price US_price
gen aus_us=r(rho)
bysort fyear: corr Belgium_price US_price
gen bel_us=r(rho)
bysort fyear: corr Brazil_price US_price
gen bra_us=r(rho)
bysort fyear: corr Canada_price US_price
gen can_us=r(rho)
bysort fyear: corr Chile_price US_price
gen chl_us=r(rho)
bysort fyear: corr China_price US_price
gen chn_us=r(rho)
bysort fyear: corr Colombia_price US_price
gen col_us=r(rho)
bysort fyear: corr Cyprus_price US_price
gen cyp_us=r(rho)
bysort fyear: corr Denmark_price US_price
gen dnk_us=r(rho)
bysort fyear: corr Finland_price US_price
gen fin_us=r(rho)
bysort fyear: corr France_price US_price
gen fra_us=r(rho)
bysort fyear: corr Germany_price US_price
gen ger_us=r(rho)
bysort fyear: corr Greece_price US_price
gen gre_us=r(rho)
bysort fyear: corr HongKong US_price
gen hkg_us=r(rho)
bysort fyear: corr India_price US_price
gen ind_us=r(rho)
bysort fyear: corr Indonesia_price US_price
gen idn_us=r(rho)
bysort fyear: corr Ireland_price US_price
gen irl_us=r(rho)
bysort fyear: corr Isreal_price US_price
gen isr_us=r(rho)
bysort fyear: corr Italy_price US_price
gen ita_us=r(rho)
bysort fyear: corr Japan_price US_price
gen jpn_us=r(rho)
bysort fyear: corr Korea_price US_price
gen kor_us=r(rho)
bysort fyear: corr Mexico_price US_price
gen mex_us=r(rho)
bysort fyear: corr Netherlands_price US_price
gen net_us=r(rho)
bysort fyear: corr Norway_price US_price
gen nor_us=r(rho)
bysort fyear: corr Peru_price US_price
gen per_us=r(rho)
bysort fyear: corr Philippines_price US_price
gen phl_us=r(rho)
bysort fyear: corr Portugal_price US_price
gen por_us=r(rho)
bysort fyear: corr Russia_price US_price
gen rus_us=r(rho)
bysort fyear: corr Singapore_price US_price
gen sng_us=r(rho)
bysort fyear: corr SouthAfrica_price US_price
gen sa_us=r(rho)
bysort fyear: corr Spain_price US_price
gen esp_us=r(rho)
bysort fyear: corr Sweden_price US_price
gen swd_us=r(rho)
bysort fyear: corr Switzerland_price US_price
gen swt_us=r(rho)
bysort fyear: corr Taiwan_price US_price
gen twn_us=r(rho)
bysort fyear: corr Thailand_price US_price
gen thl_us=r(rho)
bysort fyear: corr UK_price US_price
gen uk_us=r(rho)
bysort fyear: corr Venezuela_price US_price
gen ven_us=r(rho)
I meant to generate 39 new variables of correlation, which change every year. But I only got the correlation in the last year at the end. I will upload picture the data.
Thank you in advance!
Related Posts with generate variable that can change every year
Metanalysis (random effects model error "Convergence not achieved during tau2 estimation"*)Hello all, I am running a metanalysis using a precomputed effect size and standard error. I have no…
Repeat Sales Price IndexHello. I am currently running a project where I wish to create a price index on the returns of coll…
output logisticHi to everybody. I hope that anybody can help me!! I've calculated a crude OR. and I obtained a cert…
How to unpivot columns to create panel data?Hi all, In Excel, i'd usually use power query to unpivot columns and then copy the data into stata,…
Random-Effects Model: Sigma u equals zero, Breusch-Pagan Lagrange Multiplier equals 1(This is my first time posting something on StataList, so if my formatting or explanations are wrong…
Subscribe to:
Post Comments (Atom)
0 Response to generate variable that can change every year
Post a Comment