Lesson 10 - Topics SAS Procedures for Standard Statistical Tests and Analyses Programs 19 and 20 LSB 8:16-17
STATISTICAL PROCEDURES IN SAS
Important to understand the output
Treatment Groups in TOMHS 1.Beta Blocker 2.Calcium Channel Blocker 3.Diuretic 4.Alpha Blocker 5.ACE Inhibitor 6.Placebo are blood pressure drugs
Side Effect Questions Have you been troubled in the past 3 months with any of the following? a. Feverb. Sweatingww. Feeling depressed 1.No, not troubled 2.Yes, mildly 3.Yes, moderately 4.Yes, severely Responses 2-4 indicate a positive response.
* Program 19 DATA stat ; INFILE ‘C:\SAS_Files\tomhsfull.data' LRECL = 300 ; ptid group sbpbl sbp12 ursod12 se12_2 1. ; if se12_2 in(2,3,4) then tired12 = 1; else if se12_2 = 1 then tired12 = 2; sbpchg = sbp12 - sbpbl; if group = 6 then active = 2; else active = 1; if group IN(1,2,3,4,5) then drug = group;
PROC FREQ DATA=stat; TABLES active*tired/CHISQ RELRISK; TITLE 'Chi-square Test Comparing Active vs Placebo Group for Tiredness'; RUN; CHISQ – displays Chi-square test RELRISK – displays odds ratio and relative risk Indepent Variable * dependent variable
Table of active by tired12 active tired12 Frequency‚ Percent ‚ Row Pct ‚ Col Pct ‚ 1‚ 2‚ Total ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 1 ‚ 112 ‚ 522 ‚ 634 ‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 2 ‚ 55 ‚ 170 ‚ 225 ‚ 6.40 ‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total Frequency Missing = 43 Statistic DF Value Prob ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Chi-Square Likelihood Ratio Chi-Square Continuity Adj. Chi-Square Mantel-Haenszel Chi-Square Tests if two percentages are significantly different P-value
Table of active by tired12 active tired12 Frequency‚ Percent ‚ Row Pct ‚ Col Pct ‚ 1‚ 2‚ Total ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 1 ‚ 112 ‚ 522 ‚ 634 ‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 2 ‚ 55 ‚ 170 ‚ 225 ‚ 6.40 ‚ ‚ ‚ ‚ ‚ ‚ ‚ ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total Estimates of the Relative Risk (Row1/Row2) Type of Study Value 95% Confidence Limits ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Case-Control (Odds Ratio) Cohort (Col1 Risk) RR = Risk of tiredness (Active v Placebo) RR = 17.67/24.44 = 0.72 OR = Odds of tiredness (Active v Placebo) OR = (112/522)/(55/170) = 0.66
PROC TTEST DATA=stat; VAR sbpchg; CLASS active; TITLE 'T Test Comparing Active vs Placebo Group for Change in Blood Pressure'; RUN; Testing if mean SBP change is equal between 2 groups.
Statistics Lower CL Upper CL Lower CL Variable active N Mean Mean Mean Std Dev Std Dev sbpchg sbpchg sbpchg Diff (1-2) Statistics Upper CL Variable active Std Dev Std Err Minimum Maximum sbpchg sbpchg sbpchg Diff (1-2) T-Tests Variable Method Variances DF t Value Pr > |t| sbpchg Pooled Equal <.0001 sbpchg Satterthwaite Unequal < = /1.0979
Plot Generated from PROC TTEST
PROC MEANS DATA=stat N MEAN STDERR T PRT ; CLASS group; VAR sbpchg; TITLE'Paired T-Test, Are there significant changes in SBP within each group?'; RUN; Also used for a crossover design where each patient gets each treatment in random order
Analysis Variable : sbpchg N group Obs N Mean Std Error t Value Pr > |t| ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ < < < < < <.0001 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ T-value = Mean/Std Error
* Compare 5 active drug groups; * For SBP change; PROC ANOVA DATA=stat; CLASS drug; MODEL sbpchg = drug; MEANS drug/BON ; TITLE 'ANOVA Comparing 5 Active Treatment Groups for Change in SBP '; RUN;
The ANOVA Procedure Class Level Information Class Levels Values drug Number of observations 902 NOTE: Due to missing values, only 627 observations can be used in this analysis.
Dependent Variable: sbpchg ANOVA TABLE Sum of Source DF Squares Mean Square F Value Pr > F Model Error Corrected Total = 668.5/190.7 Source DF Anova SS Mean Square F Value Pr > F drug
Bonferroni (Dunn) t Tests for sbpchg Alpha 0.05 Critical Value of t 2.82 Minimum Significant Difference 4.92 Adjusts for 15 possible pairwise comparisons Required difference between any 2 groups to be significant.
Comparisons significant at the 0.05 level are indicated by ***. Difference Simultaneous drug Between 95% Confidence Comparison Means Limits *** ***
PROC GLM DATA=stat; * GLM (General Linear Model) CLASS drug; MODEL sbpchg = drug; ESTIMATE 'BB vs Diuretic' drug ; ESTIMATE 'CCB vs Diuretic' drug ; ESTIMATE 'Alpha B vs Diuretic‘ drug ; ESTIMATE 'ACE v Diuretic' drug ; MEANS drug; TITLE ‘GLM Comparing 5 Active Treatment Groups for Change in SBP '; RUN; Compares drug 1 with drug 3
The GLM Procedure Source DF Type III SS Mean Square F Value Pr > F drug Output from estimate statements Standard Parameter Estimate Error t Value Pr > |t| BB vs Diuretic CCB vs Diuretic Alpha B vs Diuretic ACE v Diuretic Each group has higher BP than the diuretic group. ESTIMATE ‘Avg 2-3 v 4' drug ;
PLOT GENERATED FROM PROC GLM
Distribution of Urinary Sodium Excretion
PROC NPAR1WAY DATA=stat WILCOXON ; CLASS drug; VAR ursod12; * Skewed distribution; TITLE 'Non-parametric Test Comparing Groups in Urinary Sodium'; RUN; *The values for ursod12 are ordered from lowest to highest and given a value of 1 to N. Analyses is then done on these ranked values.
Wilcoxon Scores (Rank Sums) for Variable ursod12 Classified by Variable drug Sum of Expected Std Dev Mean drug N Scores Under H0 Under H0 Score ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Average scores were used for ties. Kruskal-Wallis Test Chi-Square DF 4 Pr > Chi-Square Of values drug N Median ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
* Program 20 * Chi-square tests from summary counts; DATA asthma; INFILE DATALINES; INPUT ses asthma count; DATALINES; ; Asthma SES |YES | NO | LOW | 40 | 100 | HIGH | 30 | 130 |
SAS LOG 1 DATA asthma; 2 INFILE DATALINES; 3 INPUT ses asthma count; 4 DATALINES; NOTE: The data set WORK.ASTHMA has 4 observations and 3 variables.
PROC FREQ DATA=asthma; TABLES ses*asthma/CHISQ RELRISK ; WEIGHT COUNT; TITLE 'Relationship between Asthma and SES'; RUN; ses asthma Frequency| Percent | Row Pct | Col Pct |1 |2 | Total | 40 | 100 | 140 | | | | | | | | | | 30 | 130 | 160 | | | | | | | | | Total Odds Ratio (Relative Odds) (40/100)/(30/130)= 1.73 Note: This is the odds ratio of having asthma (low v high SES)
Statistics for Table of ses by asthma Statistic DF Value Prob Chi-Square Estimates of the Relative Risk (Row1/Row2) Type of Study Value 95% Confidence Limits Case-Control Loosely speaking: There is a 73% increase chance of asthma if you are low SES (versus high SES).