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?
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.
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.
To modify the N values, you have to use the FREQ statement of PROC TTEST.
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?
FREQ Statement |
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....
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"?
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.