SAS: Statistical Analysis




Let's look at some of the statistical tests available to the analyst in SAS.

Importing the Data:

Let's import the hsb datasetfirst.Check thedownloadssection to download this file.

Timeout! Trying to finally up grade the bland feel with my own branding. Thinking regarding the modern look of https://rnrheatingandcooling.com? Undeniably a dazzling furnace install service in Bridgeport if ever required inside the general CONNECTICUT location. Send a comment. Appreciate it!

1234PROC IMPORT DATAFILE = '/folders/myshortcuts/Datasets/SAS Statistical Tests/HSB.csv'OUT = Students DBMS = csv REPLACE;GETNAMES = YES;RUN;

The hsbcontainssamples ofhigh school students' read, write, math and science score on college standardized tests. The dataset codes are as follows:

VariableCode Descriptionid0malegender1femalerace1hispanicrace2asian3african-american4caucasianses1lowsocio-economic standing2middle3highschtyp1publicschool type2privateprog1generalprogram type2academic3vocationalreadreading scorewritewriting scoremathmath scoresciencescience scoresocstsocial studies score

1. T-TESTS

In order to make generalized observations about the entire population based on this sample, we first need to make sure those observations are statistically significant. In general we will use a 95% confidence interval and our p-values need to be <= .05to accept the null or primary hypothesis.

ONE-SAMPLE T-TEST

To test whether the 'Write' scores differ significantly from 50;
Our hypothesis: the write scores do not differ from 50 in a statistically significant way.
SIDES OPTION: 2(2-tailed), L(left-tailed), U(right-tailed)

123PROC TTEST DATA = Students h0 = 50 SIDES=2 alpha=0.1;VAR write;RUN;

Since our p-value< .001 we reject our hypothesis and conclude that mean write scores do differ significantly from 50. We accept the value of 52.775.

TWO-SAMPLE T-TEST ( FOR INDEPENDENT VARIABLES)

We wish to test whether our hypothesis, that write mean is the same for males and females is statistically significant.

1234PROC TTEST DATA = Students;CLASS female;VAR write;RUN;

The results indicate that there is a statistically significant difference between themean writing score for males and females (t = -3.73, p = .0002).In other words, females have a statistically significantly higher mean score on writing (54.991) than males (50.121).

TWO-SAMPLE T-TEST (PAIRED/DEPENDENT VARIABLES)

Since write/read values are for the same student they are dependent.

Our hypothesis: There is no differences in means for write/read.

123PROC TTEST DATA = Students;PAIRED write*read;RUN;

Since our p-value=0.38 we accept our null hypothesis, that there is no statistically significant difference between read and write scores.

ONE-SAMPLE BINOMIAL TEST (TEST OF PROPORTIONS)

To see whether the proportion of females differs significantly from 50%;
Our hypothesis: female proportion is 50%
The alternate hypothesis: female proportion is not 50%;

1234PROC FREQ DATA = Students;TABLES female / BINOMIAL(p=.5);EXACT BINOMIAL;RUN;

We find that our two-tailed p-value is 0.22 (much higher than a .05 cutoff for 95% confidence intervals) and we accept that the female proportion is 50%.

2. CHI-SQUARE TESTS

Chi-Square tests can be used to test statistical significance in two or more variables. In the case of T-tests, you are limited to two variables. Furthermore, it can also be used to test associations between categorical as well as character variables.

CHI-SQUARE GOODNESS OF FIT

Test our hypothesis that the sample dataset contains races in expected proportions of 10% Hispanic,
10% Asian, 10% African American and 70% Caucasian

123PROC FREQ DATA = Students;TABLES race / CHISQ TESTp=(10 10 10 70);RUN;

Since our p-value = 0.1697 we accept our hypothesis that the observations are in the expected proportions

CHI-SQUARE: TEST OF ASSOCIATION

To test whether there is a relationship between type of school attended and gender
Note: The null hypothesis in a Chi-Sqr test is always stating independence and we use the two-sided p-value.

123PROC FREQ DATA = Students;TABLES schtyp*female / CHISQ;RUN;

Since our p-value=0.8283 (see the Prob column in the Chi-Square statistic table), we accept the null hypothesis that they are independent at the 95% confidence level.

3. CORRELATION

Let's say we want to know whether math and science scores are correlated. For this we'll use PROC CORR:

123PROC CORR DATA = Students;VAR math science;RUN;

It seems that Math and Science scores have a moderately strong positive correlation of 0.6. Also, this is statistically significant with a p-value < .0001.

4. TWO-WAY ANOVA

ANOVA can be used to assess the effects on one variable by a combination of other variables.

For example, for a retail store dataset, Is there an impact on Brand A from aisle and shelf placement of Brand A's product?

To do TWO-WAY Anova, first figure out the response variable and the influencer variables. Let's simulate some data for Sales, Aisle and Shelf placement of product Brand A.
Influencer Variables: Shelf, Aisle
Response Variable: Sales

We wish to study the effects of aisle and shelf placements on sales (our response variable).In order to do this we will conduct a 2-way anova to assess the effects of shelf and aisle on sales. In
addition we will assess whether there is any interaction between shelf and aisle.

H0: The population means of the sales are same across the three shelves (does not affect Sales)
H0: The population means of the sales are same across the three aisles(does not affect Sales)
H0: There are no dependencies between aisles and shelves(does not affect Sales)

We accept H0 if the p-value is >.05

Simulate the Sales Data:1234567891011121314151617181920212223DATA Sales_Data;INPUT @1 Sales @6 Aisle @8 Shelf;CARDS;10.7 1 110.9 1 111.3 1 111.2 1 211.6 1 210.9 1 210.8 2 111.1 2 110.7 2 111.9 2 212.2 2 211.7 2 212.2 3 112.3 3 112.5 3 110.9 3 211.6 3 211.9 3 2;RUN;Run the ANOVA:1234PROC GLM DATA = Sales_Data;CLASS Shelf Aisle; *The class specifies the character variables;MODEL Sales = Aisle | Shelf;RUN;

Looking at the p-values:

Aisle: .003 (reject Ho)

Shelf: 0.32 (accept Ho)

Aisle*Shelf: .0007 (reject Ho)

It seems that combined, Aisle and Shelf does have an impact on Sales. However,, Shelf placement by itself doesnot seem to impact sales but Aisle placement does.

Bless you followers! I'd Facebooked a buddy I could certainly describe her great awesome Canada based CPA training service with hearts, https://dcscpa.com/ during a suitable write-up. So if you're researching to find a cpa training service inside of the whole Nova Scotia sector, they really really are incredible.

Of course, naturally I must bring up the initial thought for this unique write-up has been provided by with aquabec.ca. They certainly are a great storage tank manufacturers. I always treasure a great idea!

Inspirations For This Article

https://pigeonmail.to - Definitely worth checking out.
http://crglass.ca - Thank you Karlie. I realize you're incredibly busy. Appreciate your making the time!
https://www.lottadigital.com - I vow the next time, it's me returning the favour!
http://southpacifickayaks.com - I declare the very next time, it's me giving back the favour.
https://energytap.ca - Thanks a lot for the critique. I am just the most horrible speller!

Posted in Programming Post Date 01/15/2025


Comments

Name


Email


Website


Comment


Recent Posts