turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- two sample t-test

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-28-2016 04:56 PM

Hi,

I have 5 numerical variables and I am trying to run a t-test to figure out if the variables are equal.

I tried to use the following t-test statement:

proc ttest data=econttest ;

title "Two sample t-test Econ";

class zero;

var one;

run;

But I received the following error: ERROR: The CLASS variable has more than two levels.

So, I used a proc GLM as follows:

proc glm data=Econttest;

class zero;

model one = zero;

lsmeans zero / pdiff;

run;

Would you please let me know if I am using the right statements? If not which statement shoild I use?

I have attached my output.

Thank you,

Niloo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-28-2016 05:39 PM

Have you changed your data format or maintained that format in SAS, ie one column per variable?

If so, then your data is not structured to facilitate the comparison in SAS, so your code and results are incorrect.

Change your data so that you have a variable that identifies the Variable and another that holds the value.

Proc Transpose can be used to transform your data.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-28-2016 07:40 PM

Dear Reeza,

Thank you for your response. I have not changes my data format. I did some research on proc transpose, is this how I can use it?

proc transpose data=econttest out=econttest1; by zero; run;

I am trying to find out if variable zero=one, one=two, two=three, three=four.

Thanks,

Niloo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-28-2016 07:55 PM

I don't know. Does your data look correct afterward? I doubt it, since zero doesn't appear to be a grouping variable.

Google SAS UCLA WIDE TO LONG and you'll find examples of transposing using proc transpose or a data step.

Also, if your doing mutiple t-tests its worth looking into PROC MULTTEST.

Google SAS UCLA WIDE TO LONG and you'll find examples of transposing using proc transpose or a data step.

Also, if your doing mutiple t-tests its worth looking into PROC MULTTEST.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-28-2016 08:21 PM - edited 02-28-2016 08:25 PM

You need change your data structure ,like :

data temp;

set have;

array x{*} zero one two three four;

length group $ 20;

do i=1 to dim(x);

group=vname(x{i});

value=x{i};

output;

end;

run;

/* Since your design is balanced , you can use proc anova to test */

proc anova data=have;

class group;

model value=group;

mean group/ scheffe;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-29-2016 09:45 PM

Dear Xia,

Thank you for your help. I used your codes and got the attached output. Does this table mean that non of the comparisons is significant?

Can I conclude that the none of the differences between the variables (zero, one, two, three, four) are equal?or all the H0: μ1=μ2 are rejected?

Thank you,

Niloo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-29-2016 10:10 PM

From the ANOVA the p-value is 0.019, less than 0.05, therefore you reject your null hypothesis.

However, your pairwise comparisons show no difference, where the level of significance has been corrected for multiple testing.

You didn't post your code so I can't say anything beyond this.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-29-2016 10:14 PM

Hi Reeza,

Here is the code:

data econttest;

set work.econ;

run;

data econ1;

set econttest;

array x{*} zero one two three four;

length group $ 20;

do i=1 to dim(x);

group=vname(x{i});

value=x{i};

output;

end;

run;

proc anova data=econ1;

class group;

model value=group;

mean group/ scheffe;

run;

Thanks

Niloo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-29-2016 10:23 PM

Thanks, your code doesn't change my answer.

The ANOVA shows a significant difference.

The pairwise tests do not.

Why ->

http://www.graphpad.com/guides/prism/6/statistics/index.htm?stat_results_post_tests_2.htm

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-01-2016 02:28 AM

From your output :

Number of Observations Read 805

Number of Observations Used 444

I doubted it is not balance design. So proc anova is not trusted.

Switch into PROC GLM + mean or lsmean . as Reeza suggested.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-01-2016 01:02 PM

Hi,

I am using the following the following statements but the results (attached) look funny:

data econ1;

set econttest;

array x{*} zero one two three four;

length group $ 20;

do i=1 to dim(x);

group=vname(x{i});

value=x{i};

output;

end;

run;

proc glm data=Econ1;

class zero;

model one = zero;

lsmeans zero / pdiff;

run;

Could you please tell me how I can fix my code?

Thanks,

Niloo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-01-2016 02:32 AM

From the output ,

Simultaneous 95% Confidence Limits all contains zero . so it is hard to say which group is different another group.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-01-2016 02:55 PM

You should not be using the Scheffe adjustment option. This is way too conservative. Change to Tukey, or see what happens without the option at all.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-01-2016 03:11 PM

Hi,

I ran the Proc GLM without the adjustment and the results still look funny(attached pdf is the output)

data econ;

set work.econ;

run;

proc glm data=Econ;

class zero;

model one = zero;

lsmeans zero / pdiff;

run;

Tahnks,

Niloo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-01-2016 06:00 PM

Hi again,

I went through my data and I think I have to use a paired t-test since each row in my data is related to one company. I used the following statements:

proc ttest data=econ sides=2 alpha=0.05 h0=0;

title "Paired sample t-test example";

paired zero * one;

run;

My output does not look funny anymore. Could you please chekc out my output (attached)and let me know if I have got it right this time?

Thank you very much,

Niloo