Showing posts with label Biostat. Show all posts
Showing posts with label Biostat. Show all posts

Wednesday, June 6, 2012

To select desired outputs in one PDF file


Recently, I was asked to generate a series of correlation coefficient plots (Scatter Plots). I put them in one big PDF file. Basically, the codes are like:

ods pdf file="***.pdf";
... codes for generating plots ...
ods pdf close;

Today, I was asked to add p-Values in those plots. To get p-Values, I have to use “ODS OUTPUT” (true?) to catch it by “PROC CORR”. The codes are like below:

ods output PearsonCorr=out1;
proc corr data=dataset_name PEARSON;
var x y;
run;
ods output off;

Basically, I just want the p-Value in dataset out1 from "ods output". After I add the codes, the outputs of “PROC CORR” are added to the PDF file. ouch!

Maybe, I used wrong terms. I could not find any answer from google to solve the issue. I turned back to SAS help. After researches and tests, I found a solution: adding “ods pdf exclude/select;”  to turn off/on the outputs in the PDF file. 

So the codes are like below (highlighted in light-green):

ods pdf file="***.pdf";
... codes for generating plots ...

ods pdf exclude all;
ods output PearsonCorr=out1;
proc corr data=dataset_name PEARSON;
var x y;
run;
*ods output off;
ods pdf select all;
... codes for generating plots
ods pdf close;

"PROC CORR" outputs are not shown in the pdf file. It works perfectly well.

Thursday, May 24, 2012

To flag Baseline records

As an example, the Baseline value for one assessment here is defined as the last non-missing measurement taken on or before the day of the first dosing of study drug.

Different programmers use different approaches to flag Baseline records. I used two steps (using LB domain in SDTM as an example):
1) To sort the assessment results in dataset LB througth PROC SORT by subject assessment date_time...;

PROC SORT DATA=lb;
  BY usubjid lbcat lbscat lbtestcd DESCENDING lbdtc;
RUN;

2) To flag the Baseline value with ABLFL='Y'.

 DATA lb(drop=flag); ** drop the temporary variable **;
  SET lb;
  BY usubjid lbcat lbscat lbtestcd DESCENDING lbdtc;
   ** variable flag is used to identify if one test has ABLFL marked **;
  RETAIN flag;
   ** flag=0 indicating there is no ABLFL marked yet. **; 
  IF first.lbtestcd THEN flag=0;
  ** you can add more conditions in IF logic expressions. **;
  ** TRTSDT below has the first dosing dates. **;
  IF flag=0 and LBDT <= TRTSDT and LBSTRESN ne .THEN DO;
    ABLFL='Y'; ** ABLFL='Y' indicates the baseline record. **;
    flag=1; ** flag=1 indicating the ABLFL is marked. **;
  END;
RUN;