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!
data Migraine;
input Gender $ Treatment $ Response $ Count;
datalines;
female Active Better 16 female Active Same 11
female Placebo Better 5 female Placebo Same 20
male Active Better 12 male Active Same 16
male Placebo Better 7 male Placebo Same 19
;
1
DATA Migraine;
2
INPUT Gender $ Treatment $ Response $ Count;
3
DATALINES;
4
female Active Better 16 female Active Same 11
5
female Placebo Better 5 female Placebo Same 20
6
male Active Better 12 male Active Same 16
7
male 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!
ods graphics on;
proc freq data=Migraine;
tables Gender*Treatment*Response /
relrisk plots(only)=relriskplot(stats) cmh noprint;
weight Count;
title 'Clinical Trial for Treatment of Migraine Headaches';
run;
ods graphics off;
title 'Clinical Trial for Treatment of Migraine Headaches';
7
RUN;
8
ods 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
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.