BookmarkSubscribeRSS Feed
timkill1982
Calcite | Level 5

 

 

ods output Statistics=Statistics1 TTests=TTests  Equality=Equality;
proc ttest data=&lib..&d ci=none;
weight weight1;
where BRAND in ("Overall",&company) ;;
class &condition;
var &outcome;
run;
ods output close;

When i run the following code, my output in the Statistics1 dataset is not weighted even though i have specified the weight option? Is there a work around for this?

 

 

7 REPLIES 7
FreelanceReinh
Jade | Level 19

How do you recognize that it is not weighted? Does Statistics1 remain completely unchanged if you alter the relevant values of WEIGHT1?

 

Sometimes people confuse the WEIGHT and the FREQ statement. What is the meaning of your WEIGHT1 values?

 

Ideally, you would provide some example data where we can see the issue.

timkill1982
Calcite | Level 5

Yes Statistics1 remains unchanged. By appliying the weights I would have assumed that the N values would have changed, and result in a change in the Mean values.

FreelanceReinh
Jade | Level 19

To modify the N values, you have to use the FREQ statement of PROC TTEST.

timkill1982
Calcite | Level 5
ods output Statistics=Statistics1 TTests=TTests  Equality=Equality;
proc ttest data=&lib..&d ci=none;
freq weight1;
/*weight weight1*/
where BRAND in ("Overall",&company) ;;
class &condition;
var &outcome;
run;
ods output close;

So my solution should be as above?

timkill1982
Calcite | Level 5

FREQ Statement
FREQ variable ;

The variable in the FREQ statement identifies a variable that contains the frequency of occurrence of each observation. PROC TTEST treats each observation as if it appears times, where is the value of the FREQ variable for the observation. If the value is not an integer, only the integer portion is used. If the frequency value is less than 1 or is missing, the observation is not used in the analysis. When the FREQ statement is not specified, each observation is assigned a frequency of 1. The FREQ statement cannot be used if the DATA=data set contains statistics instead of the original observations.

 

This would there for exclude a lot of my variables if the weight is less than 1....

FreelanceReinh
Jade | Level 19

Well, if variable WEIGHT1 contains integer values, which are the frequency of occurrence of each observation, the FREQ statement is appropriate, not the WEIGHT statement.

 

That said, you have to make sure that the rest of your statements in conjunction with your data is compatible with the assumptions of a two-sample t-test. For example, do you really have two independent samples from separate groups? What is the relationship between items represented by observations with BRAND=&company and items represented by observations with BRAND="Overall"?

Rick_SAS
SAS Super FREQ

Here's an explanation of the difference between the WEIGHT and FREQ statements in SAS. Although the discussion is for regression, the same ideas hold for PROC TTEST.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 7 replies
  • 2943 views
  • 1 like
  • 3 in conversation