options fmtsearch=(lib) NODATE; libname lib "C:\Documents and Settings\Pantelis Andreou\My Documents\Pantelis\Classes\Data\Nshs"; proc format; value agef 18 - 34 = '18-34' 35 - 64 = '35-64' 65 - HIGH = '65+ ' ; value bmif . = " " 0.00 - 18.49 = "Under Wt. " 18.50 - 24.99 = "Normal Wt." 25.00 - 29.99 = "Overweight" 30.00 - HIGH = "Obese " ; value cholf . = " " 0.00 - 5.19 = "Low Risk " 5.20 - 6.19 = "Moderate Risk" 6.20 - HIGH = "High Risk " ; value sexf . = " " 1 = "Male " 2 = "Female" ; run; data final; set lib.panhs95; agegrp = put(agegroup, agef.); bmicat = put(bmi, bmif.); cvdrisk = put(chol, cholf.); sex2 = put(sex, sexf.); run; /* Description Control Statistical Analysis AGREE requests tests and measures of classification agreement ALL requests tests and measures of association produced by CHISQ, MEASURES, and CMH ALPHA= sets the confidence level for confidence limits BDT requests Tarone's adjustment for the Breslow-Day test BINOMIAL requests binomial proportion, confidence limits and test for one-way tables BINOMIALC requests BINOMIAL statistics with a continuity correction CHISQ requests chi-square tests and measures of association based on chi-square CL requests confidence limits for the MEASURES statistics CMH requests all Cochran-Mantel-Haenszel statistics CMH1 requests the CMH correlation statistic, and adjusted relative risks and odds ratios CMH2 requests CMH correlation and row mean scores (ANOVA) statistics, and adjusted relative risks and odds ratios CONVERGE= specifies convergence criterion to compute polychoric correlation FISHER requests Fisher's exact test for tables larger than 2 ×2 JT requests Jonckheere-Terpstra test MAXITER= specifies maximum number of iterations to compute polychoric correlation MEASURES requests measures of association and their asymptotic standard errors MISSING treats missing values as nonmissing PLCORR requests polychoric correlation RELRISK requests relative risk measures for 2 ×2 tables RISKDIFF requests risks and risk differences for 2 ×2 tables RISKDIFFC requests RISKDIFF statistics with a continuity correction SCORES= specifies the type of row and column scores TESTF= specifies expected frequencies for a one-way table chi-square test TESTP= specifies expected proportions for a one-way table chi-square test TREND requests Cochran-Armitage test for trend Control Additional Table Information CELLCHI2 displays each cell's contribution to the total Pearson chi-square statistic CUMCOL displays the cumulative column percentage in each cell DEVIATION displays the deviation of the cell frequency from the expected value for each cell EXPECTED displays the expected cell frequency for each cell MISSPRINT displays missing value frequencies SPARSE lists all possible combinations of variable levels even when a combination does not occur TOTPCT displays percentage of total frequency on n-way tables when n>2 Control Displayed Output CONTENTS= specifies the HTML contents link for crosstabulation tables CROSSLIST displays crosstabulation tables in ODS column format FORMAT= formats the frequencies in crosstabulation tables LIST displays two-way to n-way tables in list format NOCOL suppresses display of the column percentage for each cell NOCUM suppresses display of cumulative frequencies and cumulative percentages in one-way frequency tables and in list format NOFREQ suppresses display of the frequency count for each cell NOPERCENT suppresses display of the percentage, row percentage, and column percentage in crosstabulation tables, or percentages and cumulative percentages in one-way frequency tables and in list format NOPRINT suppresses display of tables but displays statistics NOROW suppresses display of the row percentage for each cell NOSPARSE suppresses zero cell frequencies in the list display and in the OUT= data set when ZEROS is specified NOWARN suppresses log warning message for the chi-square test PRINTKWT displays kappa coefficient weights SCOROUT displays the row and the column scores Create an Output Data Set OUT= specifies an output data set to contain variable values and frequency counts OUTCUM includes the cumulative frequency and cumulative percentage in the output data set for one-way tables OUTEXPECT includes the expected frequency of each cell in the output data set OUTPCT includes the percentage of column frequency, row frequency, and two-way table frequency in the output data set */ /* Exact Statistics Computed AGREE McNemar's test for 2 ×2 tables, simple kappa coefficient, and weighted kappa coefficient BINOMIAL binomial proportion test for one-way tables CHISQ chi-square goodness-of-fit test for one-way tables; Pearson chi-square, likelihood-ratio chi-square, and Mantel-Haenszel chi-square tests for two-way tables COMOR confidence limits for the common odds ratio for h ×2 ×2 tables; common odds ratio test FISHER Fisher's exact test JT Jonckheere-Terpstra test KAPPA test for the simple kappa coefficient LRCHI likelihood-ratio chi-square test MCNEM McNemar's test MEASURES tests for the Pearson correlation and the Spearman correlation, and the odds ratio confidence limits for 2 ×2 tables MHCHI Mantel-Haenszel chi-square test OR confidence limits for the odds ratio for 2 ×2 tables PCHI Pearson chi-square test PCORR test for the Pearson correlation coefficient SCORR test for the Spearman correlation coefficient TREND Cochran-Armitage test for trend WTKAP test for the weighted kappa coefficient */ /* Procedures That Support the WEIGHT Statement CORR FREQ MEANS/SUMMARY REPORT STANDARD TABULATE UNIVARIATE Note: In PROC FREQ, the value of the variable in the WEIGHT statement represents the frequency of occurrence for each observation. See the PROC FREQ documentation for more information. */ /* Descriptive statistic keywords COLPCTN PCTSUM COLPCTSUM RANGE CSS REPPCTN CV REPPCTSUM KURTOSIS | KURT ROWPCTN LCLM ROWPCTSUM MAX SKEWNESS | SKEW MEAN STDDEV|STD MIN STDERR N SUM NMISS SUMWGT PAGEPCTN UCLM PAGEPCTSUM USS PCTN VAR Quantile statistic keywords MEDIAN|P50 Q3|P75 P1 P90 P5 P95 P10 P99 Q1|P25 QRANGE Hypothesis testing keywords PROBT T */ ods pdf file="C:\Documents and Settings\Pantelis Andreou\My Documents\Biostats\Bcs\Shrug\Proc Frequency Examples.pdf"; proc tabulate data=final order=data; class hyper region; weight pwgtq; tables hyper, region="Region of Residence (%)"*pctn="" / row=float rts=25; TITLE1 "Example 1: Simple"; TITLE2 "Hypertension risk by region - showing column percent/Wrong weights"; run; proc freq data=final order=data; weight pwgtq; tables hyper*region/chisq nofreq norow nopercent; exact chisq; label region="Region of Residence (%)"; TITLE1 "Example 1: Simple"; TITLE2 "Hypertension risk by region - showing column percent"; run; proc tabulate data=final order=data; class hyper region; freq pwgtq; weight pwgtq; tables hyper, region="Region of Residence (%)"*pctn="" / row=float rts=25; TITLE1 "Example 1: Simple"; TITLE2 "Hypertension risk by region - showing column percent/Right weights"; run; proc tabulate data=final order=data; class bmicat sex2 agegrp; freq pwgtq; weight pwgtq; tables sex2=""*agegrp=""*pctn="", bmicat="BMI Distribution (%)" / row=float rts=25; TITLE1 "Example 2: A little more complicated"; TITLE2 "Body mass index distribution by sex and age group - showing row percent/Right weights"; run; proc freq data=final order=data; weight pwgtq; tables sex2*agegrp*bmicat/ nofreq nocol nopercent out=ex2 sparse outpct; label bmicat="BMI Distribution (%)"; TITLE1 "Example 2: A little more complicated"; TITLE2 "Body mass index distribution by sex and age group - showing row percent"; run; proc print data=ex2; run; *title1; *title2; ods pdf close;