Published on :
Statistique CREATION_INTERNE

Documentation Example 7 for PROC FREQ

This code is also available in: Deutsch Español Français
Awaiting validation
The script initializes a dataset named Migraine containing information on gender, treatment, response, and a count for each combination. It then uses PROC FREQ to analyze this data. The procedure generates cross-frequency tables between Gender, Treatment, and Response, calculates relative risks, and Cochran-Mantel-Haenszel statistics. The ODS Graphics option is enabled to produce a relative risk plot. The weight of observations for calculations is specified by the Count variable. The report title is set as 'Clinical Trial for Treatment of Migraine Headaches'.
Data Analysis

Type : CREATION_INTERNE


The 'Migraine' dataset is created directly within the SAS script using 'datalines', meaning the data is embedded in the code itself and does not come from an external source or existing SAS libraries (like SASHELP).

1 Code Block
DATA STEP Data
Explanation :
This code block creates a SAS dataset named 'Migraine'. It defines four variables: 'Gender' (character), 'Treatment' (character), 'Response' (character), and 'Count' (numeric). The data is then read directly from the subsequent lines ('datalines'), with each line representing an observation and values assigned to the corresponding variables.
Copied!
1DATA Migraine;
2 INPUT Gender $ Treatment $ Response $ Count;
3 DATALINES;
4female Active Better 16 female Active Same 11
5female Placebo Better 5 female Placebo Same 20
6male Active Better 12 male Active Same 16
7male Placebo Better 7 male Placebo Same 19
8;
2 Code Block
PROC FREQ
Explanation :
This code block executes the 'FREQ' procedure on the 'Migraine' dataset. The 'tables' statement requests cross-frequency tables for the Gender, Treatment, and Response variables. The 'relrisk' and 'cmh' options respectively request the calculation of relative risks and Cochran-Mantel-Haenszel statistics. 'plots(only)=relriskplot(stats)' generates a relative risk plot via ODS Graphics (which is enabled by 'ods graphics on' and disabled by 'ods graphics off'). The 'noprint' option suppresses the display of default frequency tables. 'weight Count' indicates that the 'Count' variable should be used as the weight for frequencies and statistics. A title is also defined for the report.
Copied!
1ods graphics on;
2PROC FREQ DATA=Migraine;
3 tables Gender*Treatment*Response /
4 relrisk plots(only)=relriskplot(stats) cmh noprint;
5 weight Count;
6 title 'Clinical Trial for Treatment of Migraine Headaches';
7RUN;
8ods graphics off;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : S A S S A M P L E L I B R A R Y NAME: FREQEX7 TITLE: Documentation Example 7 for PROC FREQ PRODUCT: STAT SYSTEM: ALL