%let outfolder = Z:\hz2\Students\ctliu\AOT\; *this is where to save output data for FBAT; %let input = Z:\hz2\Students\ctliu\AOT\datain.txt; *this is the input file; %let K=4; *ordinal levels are 0, 1, 2, ..., K-1, for &response, K=12, for HSI5, K=8,for FTQ12, K=5 HI8; %let response= ot; *ordinal trait variable name; *no need to change below; *import data into sas; PROC IMPORT OUT= WORK.one DATAFILE= "&input" DBMS=TAB REPLACE; GETNAMES=YES; RUN; proc sort data=one; by FamID IndID; run; *proportional odds model with age, gender, race as covariates; proc genmod data=one; class gender; model &response= Gender Age / link=clogit dist=multinomial; output out=res_&response p=pred1; run; *extract the est_&responseimates for 1-\gamma(y_{ij})-\gamma(y_{ij}-1); data final_&response; set res_&response; drop _order_ _level_ pred1 gamma; retain gamma 0; if &response NE . and _level_ eq &response then do; est_&response=1-pred1-gamma; output; end; else if &response NE . and &response eq (&K-1) and _level_ eq (&K-2) then do; est_&response=-pred1; output; end; else if &response eq . and _level_ eq 0 then output; gamma=pred1; if _level_ eq (&K-2) then gamma=0; run; data two_final_&response; merge one final_&response; by FamID IndID; run; *save data to an excel file; PROC EXPORT DATA= Work.two_final_&response OUTFILE= "&outfolder\qt_&response" DBMS=EXCEL2000 REPLACE; RUN;