11-25-2015 05:11 AM - edited 11-25-2015 05:18 AM
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?
11-25-2015 05:47 AM
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.
11-25-2015 05:49 AM
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.
11-25-2015 05:59 AM
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?
11-25-2015 06:41 AM
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....
11-25-2015 06:44 AM
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"?
11-25-2015 08:18 AM
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.