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

 

Hello Everyone,

 

I have two datasets Pr_table5 (test) and C_table5 (control).

Each table consists of CD3 tested on different time intervals (day 0 day3 day7 day14 day30) with different n on each day. For example, day0 N is 63, and day30 N is 50

 

I am calculating a t-test comparing Pr_table5 and C_table5 to get the following table:

 

T-Tests

Variable

Method

Variances

DF

t Value

Pr > |t|

mean

Pooled

Equal

XX

XX

XX

mean

Satterthwaite

Unequal

XX

XX

XX

 

So I calculated the mean for Pr_table5 (mean of day0, mean of day3...) and c_table5  (mean of day0, mean of day3...) and dropped n min max std so that it will have only mean from table1 and table 2.

 

proc means data = Pr_table5 noprint;
output out = a(drop = _type_ _freq_ );
run;
proc transpose data = a out = a (drop  = n min max std ) ;
id _STAT_;
run;

proc means data = c_table5 noprint;
output out = b(drop = _type_ _freq_ );
run;

proc transpose data = b out = b (drop  = n min max std ) ;
id _STAT_;
run;

 

Then I merged two tables  (combo) which contain means from two tables.

 

data combo_a;
set a ;
_name_ = 'mean_a';
run;
data combo_b;
set b ;
_name_ = 'mean_b';
run;
data combo;
set combo_a combo_b;
run;

 

Next, I did a t-test. 

 

proc means data=combo noprint;
var mean;
by _name_;
output out=new_combo;
run;
proc ttest data=new_combo nobyvar;
class _name_;
var mean;
run;

Please let me know if there is a better approach, from both a statistical and programming point of view.

 

Thank you,
Madhu

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Can you do it directly on the raw data? SAS can analyze the difference between summarized data but this seems a bit weird to me. 

 

Are you certain the code posted works correctly because it seems like you'd only have a single observation and PROC TTEST expects multiple. Or it expects the more data from PROC MEANS, specifically the N and STD usually. 

 

 

data combo;
set pr_table5 c_table5 (indsname=source);
dset = source;
run;

*really don't think you need this step but if you think you do for some reason;
proc means data=combo nway stackods mean;
class dset;
ods output summary = combo_means;
run;

proc ttest data=combo_means;
class dset;
var mean;
run;

Here's an example of how to do PROC TTEST on raw data. 

https://stats.oarc.ucla.edu/sas/modules/an-overview-of-statistical-tests-in-sas/

 

If you have repeated measures as well, is there a reason you're aren't using a repeated measures type of analysis instead of just PROC TTEST?

https://documentation.sas.com/doc/en/statug/15.2/statug_glm_examples07.htm

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User

Can you do it directly on the raw data? SAS can analyze the difference between summarized data but this seems a bit weird to me. 

 

Are you certain the code posted works correctly because it seems like you'd only have a single observation and PROC TTEST expects multiple. Or it expects the more data from PROC MEANS, specifically the N and STD usually. 

 

 

data combo;
set pr_table5 c_table5 (indsname=source);
dset = source;
run;

*really don't think you need this step but if you think you do for some reason;
proc means data=combo nway stackods mean;
class dset;
ods output summary = combo_means;
run;

proc ttest data=combo_means;
class dset;
var mean;
run;

Here's an example of how to do PROC TTEST on raw data. 

https://stats.oarc.ucla.edu/sas/modules/an-overview-of-statistical-tests-in-sas/

 

If you have repeated measures as well, is there a reason you're aren't using a repeated measures type of analysis instead of just PROC TTEST?

https://documentation.sas.com/doc/en/statug/15.2/statug_glm_examples07.htm

 

 

Madhu6
Calcite | Level 5

Hello Reeza and everyone,

 

Thank you so much for your input. 

 

Please see the attachments for control and test datasets. Here is the code to import them.

 

proc import out=Control datafile='C:\Users\SDSP\Desktop\Control.txt';
run;
proc import out=Test datafile='C:\Users\SDSP\Desktop\Test.txt';
run;

Treatment : '1' is control and '2' is test.

Then I merged the two tables by treatment.

 

data final_table;
merge control Test;
by Treatment;
run;

Now I want to compare the two groups (control and test) and see if they are different:

I used the below code (I am sure it is not correct). Can someone please help me with this

 

proc glm;
class Treatment;
model Day0--Day720 =
Treatment */ nouni;
repeated 8 (0 3 7 15 30 90 180 360 720) polynomial / summary printe;
run;

Thank you,

Madhu

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 623 views
  • 4 likes
  • 2 in conversation