Hi Stata users, I need your help with something that is driving me crazy!
I'm calculating the Spearman rank coefficient of a variable (occupation ranked by job satisfaction) in different years. In order to do this, I am creating several datasets (one for each waves that I have) in the following way:
cd "C:\Users\Randone\Desktop\PHD\Upgrading\analisi\ES S\analisi"
use "Ess_merged.dta", clear
preserve
drop if essround != 3
bys isco88h9_ct : egen perc_sat =mean((job_sat>7)& !mi(job_sat)) /// isco88h9_ct = occupations
collapse perc_sat, by( isco88h9_ct)
egen r_d6 = rank (perc_sat), unique
sort r_d6
save d6, replace
restore
After this, I am calculating the Spearman for each couple of datasets:
cd "C:\Users\Randone\Desktop\PHD\Upgrading\analisi\ES S\analisi"
use "d6.dta", clear
merge 1:1 isco88h9_ct using d10
spearman r_d6 r_d10
Everything seems working, but what is really strange to me is that if I run the same command more than once, the Spearman coefficient is not exactly the same, but varies a bit (for instance, the first time is 0.1113 and the second 0.1182). Do you have any clues on why? I use exactly the same procedure in creating the yearly datasets, so why does Stata give me different values? The problem lies in the creation of datasets, because if I do not run again the first block of code above the Spearman is always the same.
Could you help me please? Thanks a lot, G.P.
I'm calculating the Spearman rank coefficient of a variable (occupation ranked by job satisfaction) in different years. In order to do this, I am creating several datasets (one for each waves that I have) in the following way:
cd "C:\Users\Randone\Desktop\PHD\Upgrading\analisi\ES S\analisi"
use "Ess_merged.dta", clear
preserve
drop if essround != 3
bys isco88h9_ct : egen perc_sat =mean((job_sat>7)& !mi(job_sat)) /// isco88h9_ct = occupations
collapse perc_sat, by( isco88h9_ct)
egen r_d6 = rank (perc_sat), unique
sort r_d6
save d6, replace
restore
After this, I am calculating the Spearman for each couple of datasets:
cd "C:\Users\Randone\Desktop\PHD\Upgrading\analisi\ES S\analisi"
use "d6.dta", clear
merge 1:1 isco88h9_ct using d10
spearman r_d6 r_d10
Everything seems working, but what is really strange to me is that if I run the same command more than once, the Spearman coefficient is not exactly the same, but varies a bit (for instance, the first time is 0.1113 and the second 0.1182). Do you have any clues on why? I use exactly the same procedure in creating the yearly datasets, so why does Stata give me different values? The problem lies in the creation of datasets, because if I do not run again the first block of code above the Spearman is always the same.
Could you help me please? Thanks a lot, G.P.
Comment