Hi Guys,
I have two columns of observations, and the numbers of observations are different, what I want to do is to test whether the difference between their average value are different from zero, (using t test) how could i do it?
For example,
a b
1 3
2 7
3 8
8 6
5 10
9 8
10
15
1
7
Change your data organisation to
group value
a 1
b 3
a 2
b 7
... etc
and call proc ttest with group as the class variable and value as the var variable.
Hi,
data cc01a; set temp03; keep wml; run;
data cc01b; set btemp03; keep wml1;run;
data cc01; merge cc01a cc01b; run;
data cc02; set cc01;
diff_wml=wml-wml1;
run;
proc means data=cc02 n mean t probt;
var diff_wml;
output out=cc03 n=size mean=m t=tval probt=pvalue;
run;
I did in this way, but the final result for diff_wml was different from the difference between (average wml - average wml1)
Songchan
As stated by @PGStats , you need to re-organize the data as he suggested and then use PROC TTEST.
PROC MEANS will not produce the result you want in this case.
Hi,
Thank you for your reply. But how could I reorganize the data in that way.
SC.
Hi,
Thank you!!!
If I have a lot of observations in each column, what I need to do?
"what I need to do"
You need to post representative sample data so we can understand what you're dealing with.
Post sample data in the form of a "data have" step as I've done and then show us how the desired result should look like.
"If I have a lot of observations in each column"
A table has rows (observations) and columns (variables). For this reason your statement doesn't make sense.
HI,
this is what my data looks like, i need to test whether (average wml - average wml1) is different from zero.
You need to append your datasets.
This assumes your input data set name is HAVE, and your variable names are Var1, var2.
You may need to add parenthesis to the Keep variable list.
Data want;
Set have (in=a keep=var1)
Have (in=b drop=var1 rename=var2=var1);
If a then group=‘A’;
Else group=‘B’;
Run;
@Songchan wrote:
HI,
this is what my data looks like, i need to test whether (average wml - average wml1) is different from zero.
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!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: