Rather than sorting every combination of variables, I ordered the variable1 list and variable2 list separately in an Excel file which was then imported in a SAS file called output_sort_order. The final output file was then exported to Excel. Here is the code that I used:
ods output conflimits=temp.conf
ttests =temp.ttest;
PROC TTEST plots=none
data=temp.SVI_hyst_output_SAS_dum;
paired SVI_high_flag * (&SVI_var_list.)
SVI_low_flag * (&SVI_var_list.)
SVI_SES_high_flag * (&SVI_var_list.)
SVI_SES_low_flag * (&SVI_var_list.)
SVI_HHcomp_high_flag * (&SVI_var_list.)
SVI_HHcomp_low_flag * (&SVI_var_list.);
RUN;
PROC SORT data=temp.conf;
BY variable1 variable2;
RUN;
PROC SORT data=temp.ttest;
BY variable1 variable2;
RUN;
DATA temp.SVI_hyst_ttest;
MERGE temp.conf temp.ttest;
BY difference;
sig_level = " ";
IF probt >= .05 THEN sig_level = "NS";
ELSE IF probt <= .05 AND probt > .01 THEN sig_level = "*";
ELSE IF probt <= .01 AND probt > .001 THEN sig_level = "**";
ELSE IF probt <= .001 THEN sig_level = "***";
RUN;
PROC SQL;
Create table temp.SVI_hyst_ttest_output1
as Select b.var1_sort, a.Variable1, a.Variable2, a.Difference, a.Mean,
a.sig_level, a.LowerCLMean, a.UpperCLMean, a.StdDev, a.LowerCLStdDev, a.UpperCLStdDev,
a.UMPULowerCLStdDev, a.UMPUUpperCLStdDev, a.tValue, a.DF, a.Probt
From temp.SVI_hyst_ttest a LEFT JOIN temp.output_sort_order b
On a.variable1 = b.variable1
Order by var1_sort;
QUIT;
PROC SQL;
Create table temp.SVI_hyst_ttest_output_final
as Select a.var1_sort, b.var2_sort, a.Variable1, a.Variable2, a.Difference, a.Mean,
a.sig_level, a.LowerCLMean, a.UpperCLMean, a.StdDev, a.LowerCLStdDev, a.UpperCLStdDev,
a.UMPULowerCLStdDev, a.UMPUUpperCLStdDev, a.tValue, a.DF, a.Probt
From temp.SVI_hyst_ttest_output1 a LEFT JOIN temp.output_sort_order b
On a.variable2 = b.variable2
Order by var1_sort, var2_sort;
QUIT;
... View more