BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Guerraje
Quartz | Level 8

Hello,

 

I am trying to run a t-test for age as it is continuous. I need to find the mean age and p value for age. With the code below I am able to see the overall mean age. However, I am unsure how to find the mean age of my case and control groups. I have tried using Pair statements, I have tried creating a table after the VAR and these are all giving me very different but not correct outputs. Thank you for any guidance. 

 

proc ttest data= work.query;

var Baseage;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

TTest wants to test your mean against a value. Typically that means a Class variable to provide two groups and the test is are the means of the group equal. So if you have a variable that indicates "case" or "control" the syntax would be to test the means between two groups. If you don't have such a variable, then add one to your data set.

proc ttest data= work.query;
   class casecontrolvariablename;
   var Baseage;
run;

 

To get a pvalue you must test against something.

You can provide a value to test your mean against with the H0= option on the Proc statement. For example the code below will test if your mean for the Baseage variable is 21.3 (picked at random to provide a syntax example).

proc ttest data= work.query  H0= 21.3;
   var Baseage;
run;

You should know your data and provide some value that has a use.

 

 

View solution in original post

2 REPLIES 2
ballardw
Super User

TTest wants to test your mean against a value. Typically that means a Class variable to provide two groups and the test is are the means of the group equal. So if you have a variable that indicates "case" or "control" the syntax would be to test the means between two groups. If you don't have such a variable, then add one to your data set.

proc ttest data= work.query;
   class casecontrolvariablename;
   var Baseage;
run;

 

To get a pvalue you must test against something.

You can provide a value to test your mean against with the H0= option on the Proc statement. For example the code below will test if your mean for the Baseage variable is 21.3 (picked at random to provide a syntax example).

proc ttest data= work.query  H0= 21.3;
   var Baseage;
run;

You should know your data and provide some value that has a use.

 

 

Guerraje
Quartz | Level 8

I added a CLASS statement to compare against my VAR Baseage and was able to get what I was looking for.

 

Thank you so much! 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 432 views
  • 2 likes
  • 2 in conversation