DATA Step, Macro, Functions and more

Confidence interval with alpha = 0.01

Reply
Contributor
Posts: 22

Confidence interval with alpha = 0.01

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;

 

Super User
Posts: 22,820

Re: Confidence interval with alpha = 0.01

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;

 




Contributor
Posts: 22

Re: Confidence interval with alpha = 0.01

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 

Super User
Posts: 22,820

Re: Confidence interval with alpha = 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 


 

Contributor
Posts: 22

Re: Confidence interval with alpha = 0.01

The H0 is whether or not the means are different. 

Super User
Posts: 22,820

Re: Confidence interval with alpha = 0.01

Between what?

 


@Miah wrote:

The H0 is whether or not the means are different. 


 

Contributor
Posts: 22

Re: Confidence interval with alpha = 0.01

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

Super User
Posts: 22,820

Re: Confidence interval with alpha = 0.01

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


 

 

Ask a Question
Discussion stats
  • 7 replies
  • 142 views
  • 0 likes
  • 2 in conversation