Programming the statistical procedures from SAS

PROC TTEST WEIGHT NOT WORKING

Reply
Occasional Contributor
Posts: 10

PROC TTEST WEIGHT NOT WORKING

[ Edited ]

 

 

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?

 

 

Trusted Advisor
Posts: 1,115

Re: PROC TTEST WEIGHT NOT WORKING

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.

Occasional Contributor
Posts: 10

Re: PROC TTEST WEIGHT NOT WORKING

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.

Trusted Advisor
Posts: 1,115

Re: PROC TTEST WEIGHT NOT WORKING

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

Occasional Contributor
Posts: 10

Re: PROC TTEST WEIGHT NOT WORKING

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?

Occasional Contributor
Posts: 10

Re: PROC TTEST WEIGHT NOT WORKING


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....

Trusted Advisor
Posts: 1,115

Re: PROC TTEST WEIGHT NOT WORKING

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"?

SAS Super FREQ
Posts: 3,555

Re: PROC TTEST WEIGHT NOT WORKING

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.

 

Ask a Question
Discussion stats
  • 7 replies
  • 371 views
  • 1 like
  • 3 in conversation