Published on :
Statistical CREATION_INTERNE

Example 5 PROC LOGISTIC - Stratified Sampling

This code is also available in: Deutsch Español Français
Awaiting validation
This script is an example from the SAS© Sample Library. It creates a fictional dataset 'Screen' representing a case-control study (1000 sick, 1000 healthy). It then uses the LOGISTIC procedure to model the probability of disease. The PEVENT option is demonstrated to specify the actual disease prevalence in the population (0.01) as opposed to the artificial sample prevalence (0.5), which allows correcting the calculated predictive values (CTABLE, PPROB).
Data Analysis

Type : CREATION_INTERNE


Data is generated directly in the script via a Data Step using loops and the DATALINES statement.

1 Code Block
DATA STEP Data
Explanation :
Creation of the 'Screen' dataset. Uses two nested loops to generate combinations of disease status ('Present', 'Absent') and test result (1, 0). The 'input Count @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;' statement reads frequencies from datalines while maintaining the input pointer on the same line.
Copied!
1title 'Example 5. Stratified Sampling';
2 
3DATA Screen;
4 DO Disease='Present','Absent';
5 DO Test=1,0;
6 INPUT Count @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
7 OUTPUT;
8 END;
9 END;
10 DATALINES;
11950 50
12 10 990
13;
2 Code Block
PROC LOGISTIC
Explanation :
Execution of logistic regression. The 'freq' statement weights observations by the 'Count' variable. The 'pevent=.5 .01' option in the 'model' statement compares the model with the sample prevalence (.5) and the actual population prevalence (.01). The 'ctable' option generates a classification table.
Copied!
1PROC LOGISTIC DATA=Screen;
2 freq Count;
3 model Disease(event='Present')=Test
4 / pevent=.5 .01 ctable pprob=.5;
5RUN;
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 : SAS SAMPLE LIBRARY / SAS Institute Inc.