log using "Desktop\Alpha_Omega_Cohort_Scaled.smcl"

use "Desktop\Alpha_Omega_Cohort_Scaled.dta", clear

set more off

stset age_at_censoring, failure(dead==1) time0(age_at_baseline)

#Unadjusted:

stcox age_at_baseline sex xxlvldlp_lnscaled, nohr
regsave xxlvldlp_lnscaled using Results_Alpha_Omega_Cohort_Unadjusted, tstat pval ci replace 

foreach var of varlist xxlvldll_lnscaled-gp_lnscaled {
stcox age_at_baseline sex `var', nohr
regsave `var' using Results_Alpha_Omega_Cohort_Unadjusted, tstat pval ci append 
}

use Results_Alpha_Omega_Cohort_Unadjusted, clear
outsheet using Results_Alpha_Omega_Cohort_Unadjusted.txt, replace

#Adjusted for 4 metabolites:

stcox age_at_baseline sex vldld_lnscaled cit_lnscaled alb_lnscaled gp_lnscaled xxlvldlp_lnscaled, nohr
regsave xxlvldlp_lnscaled using Results_Alpha_Omega_Cohort_Adjusted_4_metabolites, tstat pval ci replace 

foreach var of varlist xxlvldll_lnscaled-gp_lnscaled {
stcox age_at_baseline sex vldld_lnscaled cit_lnscaled alb_lnscaled gp_lnscaled `var', nohr
regsave `var' using Results_Alpha_Omega_Cohort_Adjusted_4_metabolites, tstat pval ci append 
}

use Results_Alpha_Omega_Cohort_Adjusted_4_metabolites, clear
outsheet using Results_Alpha_Omega_Cohort_Adjusted_4_metabolites.txt, replace

#Adjusted for 14 metabolites (full model):

stcox age_at_baseline sex vldld_lnscaled alb_lnscaled gp_lnscaled pufafa_lnscaled glc_lnscaled xxlvldll_lnscaled leu_lnscaled phe_lnscaled shdll_lnscaled acace_lnscaled ile_lnscaled his_lnscaled val_lnscaled lac_lnscaled xxlvldlp_lnscaled, nohr
regsave xxlvldlp_lnscaled using Results_Alpha_Omega_Cohort_Adjusted_Full_model, tstat pval ci replace 

foreach var of varlist xxlvldll_lnscaled-gp_lnscaled {
stcox age_at_baseline sex vldld_lnscaled alb_lnscaled gp_lnscaled pufafa_lnscaled glc_lnscaled xxlvldll_lnscaled leu_lnscaled phe_lnscaled shdll_lnscaled acace_lnscaled ile_lnscaled his_lnscaled val_lnscaled lac_lnscaled `var', nohr
regsave `var' using Results_Alpha_Omega_Cohort_Adjusted_Full_model, tstat pval ci append 
}

use Results_Alpha_Omega_Cohort_Adjusted_Full_model, clear
outsheet using Results_Alpha_Omega_Cohort_Adjusted_Full_model.txt, replace

log close