Edit

SAS: Sample Data (Demographic Characteristics)

   Recently, I am often developing programs on SAS for clinical trial's data analysis since I have much opportunity to analyze clinical trial data.  Although I did same things in Japan (up to 2013), I am realizing that I need to do it in the US more than in Japan.  So, my programming skill needs to be improved, and I will use this blog for keeping my brain clear.  

   One of the area needed to be improved is about 'PROC SQL.'  This is the area that I am not familiar with, but a lot of programmings are using this for developing programs.  

  Before summarizing 'PROC SQL,' I will prepare a couple of sample data.  In this article, I will show sample data for demographic characteristics as follows. 

PROGRAM

*************************************************
SAMPLE DATASET: DEMOGRAPHIC
-------------------------------------------------
DEMOGRAPHIC SAMPLE DATASET
VARIABLES: DRUG (PBO OR DRG),
SUBJECT ID(SUBJECT)
SEX (MALE OR FEMALE)
AGE (AGE AT BASELINE)
WT (WEIGHT AT BASELINE)
OTHERS: 5% MISSING DATA
*************************************************;
DATA DEMOG ; 
 KEEP DOSE DRUG SUBJECT SEX AGE WT;
 CALL STREAMINIT(123456) ;

 DO DOSE=1 TO 2 ;
   DO ID=1 TO 10 ;
   /*SUBJECT ID*/
   IF DOSE=1 THEN SUBJECT = ID ;
   ELSE IF DOSE=2 THEN SUBJECT = 10+ID ;

   /*RANDOMIZED DRUG: ASSUME NO MISSING*/
   IF DOSE=1 THEN DRUG='PBO'; ELSE DRUG='DRG';

   /*SEX: MALE/FEMALE=1*/
   IF RAND('UNIFORM')<0.5 THEN SEX='MALE ';
   ELSE SEX='FEMALE';

   /*AGE: MEAN=65 YRS, SD=10*/
   AGE = ROUND(65+10*RAND('NORMAL'),1.);

   /*WEIGHT*/
   WT = ROUND(85+15*RAND('NORMAL'),.1);

   /*MISSING INFO.: 5% MISSING DATA RANDOMLY*/
   DUM1 = RAND('UNIFORM');
   DUM2 = RAND('UNIFORM');
   DUM3 = RAND('UNIFORM');
   IF DUM1<0.05 THEN AGE='' ;
   IF DUM2<0.05 THEN WT ='' ;
   IF DUM3<0.05 THEN SEX='' ;
   OUTPUT ;
   END ;
 END ;
RUN ;


OUTPUT DATASET

Search This Blog