BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
naomip
Calcite | Level 5

Hi all,

 

I am running a t-test for variables NHH and AGWRKRTYP_G. I want to modify the output from PROC TTEST using conditional logic so that if ProbF > 0.05 (from the equality output dataset) then display the Pooled method p-value and not the Satterthwaite p-value (from the ttest dataset).

 

Am I able to use conditional logic using two datasets if I do not want to merge them? Is there a way to do this with SQL? 

ODS TRACE ON;
ODS OUTPUT	TTests		=	work.ttest_nhh;
ODS OUTPUT	Equality	=	work.equality_nhh;
PROC TTEST	DATA	=	import.agworker_sub118	ALPHA	=	0.05;
	VAR	NHH;
	CLASS	AGWKRTYP_G;
	RUN;
ODS TRACE OFF;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Seems like you could use a simple macro %IF.

 

From the equality output data set, test to see if ProbF>0.05, assign a macro variable to contain a 1 or 0 depending on ProbF>0.05 or not, and then display the pooled or Satterthwaite p-value depending.

 

Example: 

 

ods output ttests=ttest;
ods output equality=equality;
proc ttest data=sashelp.class;
    class sex;
    var height;
run;

data _null_;
    set equality;
    call symputx('equality_of_variance_test',probf>0.05);
run;

%if &equality_of_variance_test %then %do;
    proc print data=ttest(where=(method='Pooled'));
    run;
%end;
%else %do;
    proc print data=ttest(where=(method=:'Satt'));
    run;
%end;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Seems like you could use a simple macro %IF.

 

From the equality output data set, test to see if ProbF>0.05, assign a macro variable to contain a 1 or 0 depending on ProbF>0.05 or not, and then display the pooled or Satterthwaite p-value depending.

 

Example: 

 

ods output ttests=ttest;
ods output equality=equality;
proc ttest data=sashelp.class;
    class sex;
    var height;
run;

data _null_;
    set equality;
    call symputx('equality_of_variance_test',probf>0.05);
run;

%if &equality_of_variance_test %then %do;
    proc print data=ttest(where=(method='Pooled'));
    run;
%end;
%else %do;
    proc print data=ttest(where=(method=:'Satt'));
    run;
%end;
--
Paige Miller
naomip
Calcite | Level 5

Thank you! That worked perfectly.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 424 views
  • 0 likes
  • 2 in conversation