BookmarkSubscribeRSS Feed
Miah
Obsidian | Level 7

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;

 

7 REPLIES 7
Reeza
Super User

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;

 




Miah
Obsidian | Level 7

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 

Reeza
Super User

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 


 

Miah
Obsidian | Level 7

The H0 is whether or not the means are different. 

Reeza
Super User

Between what?

 


@Miah wrote:

The H0 is whether or not the means are different. 


 

Miah
Obsidian | Level 7

The mean difference of the variable Potassium between the cereals whose Manufacturer is General Mills and Kelloggs... 

Reeza
Super User

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


 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2542 views
  • 0 likes
  • 2 in conversation