I am trying to determine whether or not the mean of Potassium for the cereals whose manufacturer is General Mills or Kelloggs is different with a significance level of 0.01. I am having trouble getting the right observations selected, and therefore tusing PROC TTEST for the hypothesis test. Here it is my code and the data set:
DATA cereal;
INFILE "/folders/myfolders/cereal.txt"
DLM=',' FIRSTOBS=2 DSD MISSOVER;
INPUT Name :$50. Manufacturer $ Type $ Calories Protein Sodium Fiber Carbohydrates Sugars Potassium Vitamins Weight Cups;
RUN;
PROC PRINT DATA=cereal;
RUN;
DATA cereal;
SET Cereal;
IF Manufacturer='General Mills' | Manufacturer='Kelloggs';
RUN;
PROC PRINT DATA=Cereal;
RUN;
PROC TTEST DATA=Cereal ALPHA=0.01;
CLASS Manufacturer;
VAR Potassium;
RUN;
PROC PRINT DATA=Cereal;
RUN;
What exactly is your question? Is there something wrong with the code?
@Miah wrote:
I am trying to determine whether or not the mean of Potassium for the cereals whose manufacturer is General Mills or Kelloggs is different with a significance level of 0.01. I am having trouble getting the right observations selected, and therefore tusing PROC TTEST for the hypothesis test. Here it is my code and the data set:
DATA cereal;
INFILE "/folders/myfolders/cereal.txt"
DLM=',' FIRSTOBS=2 DSD MISSOVER;
INPUT Name :$50. Manufacturer $ Type $ Calories Protein Sodium Fiber Carbohydrates Sugars Potassium Vitamins Weight Cups;
RUN;
PROC PRINT DATA=cereal;
RUN;
DATA cereal;
SET Cereal;
IF Manufacturer='General Mills' | Manufacturer='Kelloggs';
RUN;
PROC PRINT DATA=Cereal;
RUN;
PROC TTEST DATA=Cereal ALPHA=0.01;
CLASS Manufacturer;
VAR Potassium;
RUN;
PROC PRINT DATA=Cereal;
RUN;
Yes. It is not generating the output that I need. I need to determine whether or not the mean of Potassium for the cereals whose manufacturer is General Mills or Kelloggs is different with a significance level of 0.01
What exactly is your hypothesis?
Your current code tests, is the Potassium level between General Mills and Kelloggs cereals different.
@Miah wrote:
Yes. It is not generating the output that I need. I need to determine whether or not the mean of Potassium for the cereals whose manufacturer is General Mills or Kelloggs is different with a significance level of 0.01
The H0 is whether or not the means are different.
The mean difference of the variable Potassium between the cereals whose Manufacturer is General Mills and Kelloggs...
Ok, your code doesn't read the data in correctly. Check your data in Cereal data set, right after you import it.
Run a PROC FREQ on the Manufacturer column.
And read your log - does it show any errors for the code?
Also, never ever code like this:
data cereal;
set cereal;
At this point you've destroyed your original data set and no longer have access to the original data, so you need to re-read it in from scratch which is fine in this case because your data is small. If it was a larger data set that would slow you down a lot each time.
Once you make those changes, it works as expected.
@Miah wrote:
The mean difference of the variable Potassium between the cereals whose Manufacturer is General Mills and Kelloggs...
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: