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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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