15.4.08

Extracting Engine and Path name of the code
Compiled by Prajitha Nair




The input parameter in the macro will be the name of the SAS file whose path is to be determined.

%macro PathbyName(progName);

%global fullPath fullPath1 engine;
%if %index(%upcase(&progName),.SAS) eq 0 %then
%let progName=&progName..sas;

proc sql noprint;
select xpath into :fullPath
from dictionary.extfiles where
index(upcase(xpath),"%upcase(&progName) " ) gt 0 ;
select setting into :engine from sashelp.voption
where optname="ENGINE";
quit;

%let engine = %trim(&engine);
%put engine = &engine;
%let fullpath = %trim(&fullPath);

%put fullpath = &fullPath;

%mend PathbyName;

Accessing the current working directory where the file containing the SAS code is stored


Compiled by Prajitha Nair


Let the SAS editor containing the code be KR-PH-XXX-SAS-Init.sas and it is stored in a folder named SAS Programs_Final.


The following %let statements assigns the folder and editor names to macro variables pgmfld and pgm respectively.


%let pgmfld = SAS Programs_Final; /*Folder in which SAS code is stored*/
%let pgm= KR-PH-XXX-SAS-Init.sas; /*Name of the program editor*/


The following macro is then used to extract the path of the editor from sashelp.vextfl and determine the path of the folder as “dir1” and of the editor as “dir2”.


%macro filePath;
%global fpath maxRef;

proc sql noprint;
select xpath into :fPath
from sashelp.vextfl where xpath ? "&pgm";
quit;


%let fpath = %trim(&fpath);
%put &fpath;
%global dir1 dir2 pgm1 pgmfld1;
%let pgm1 =%trim(&pgm);
%let pgmfld1= %trim(&pgmfld);


data _null_;
x=length("&fpath")-length("&pgm1");
y=length("&fpath")-length("&pgm1")-length("&pgmfld1")-1;
call symput("dir2" ,trim(substr("&fpath",1,x)));
call symput("dir1" ,trim(substr("&fpath",1,y)));
run;


%mend filePath;


This macro helps in determining the path of the code and enables the code to be executed in any computer provided the SAS code is saved within a folder and the naming conventions are followed as above.

14.3.08

15.2.08

New Abode

Finally after three years of exemplary hard work of all the present & past employees of KREARA, our dream of a beautiful new office came to frution on January 27th 2008. Thanks to all our clients and employees who have helped us make this dream come true



23.11.07

Randomisation - Data sets

Compiled by Prajitha Nair
Here is a piece of code that will generate mock randomisation list that the programmers could use to generate the outputs before unblinding the data


/*Creating the dummy dataset for randomisation*/

Proc format;
value treat 1='Test'
2='Reference'
3='Placebo';
run;

/*Randomly assigning medical kit number to treatments*/
proc plan seed=111605;
factors medkit_no=220 random block=1 random/noprint;
output out=first;
treatments treat=3 cyclic (1 2 3 );
run;

proc sort data=first out=rand_trt;
by medkit_no;
run;

data rand_trt(keep=medkitno treat);
set rand_trt;
medkitno=put(medkit_no, z3.);
format treat treat.;
run;


/*merge to get the randomised patient included in the study*/
proc sort data=rand_trt;
by medkitno;
run;

proc sort data=medkit_alloc;/*sas dataset imported from mysql*/
by medkitno;
run;

data formo.randl;
merge rand_trt(in=a) medkit_alloc(in=b);
by medkitno;
run;

11.10.07

Read only access to SAS Data sets
Compiled by Soumya Gopinath

Lock the entire SAS data library by using the option Access=Readonly.

Libname libref path access= Readonly;

Silly Proc Report !
Compiled by Soumya Gopinath

An annoying period (.) appeared in the p-value column when the break statement was applied in proc REPORT. How can we eliminate this period (.) from the report (rtf file)?

Solution:
Firstly, the data type of p-value variable is numeric then the break option will replace the missing values with a period. To avoid this situation change the data type of p-value variable to character. Then the missing values will be replaced by blank space only.
Eg:
/* Create dataset with 5 variables and 8 observations*/
data test;
input usubjid $ parameter $ visit $ trtgrp result;
datalines;
001 FEV1 VISIT1 1 2.34
002 FEV1 VISIT1 3 0.98
001 FEV1 VISIT4 1 2.04
002 FEV1 VISIT4 3 1.98
001 FVC VISIT1 1 2.34
002 FVC VISIT1 3 2.98
001 FVC VISIT4 1 2.44
002 FVC VISIT4 3 1.99
;
run;
/* Carrying out ANOVA*/
ods output ModelAnova= test1;
proc glm data=test;
by parameter visit;
class trtgrp;
model result=trtgrp/ss3;
lsmeans trtgrp/adjust=t pdiff;
run;

data test2;
set test1;
test=' '; /* dummy variable*/
keep parameter visit probf Test;
run;

/* Specify the output location*/

ods rtf file="D:\soumya\test.rtf" style=styles.listingstyle;

proc report data = test2 nowd spacing = 2 headline headskip split = '*' missing;
column parameter visit test,(probf);
define parameter / group order=data left 'Parameter' ;
define visit / display left 'Timepoint' ;
define Test / across center "Test" ;
define probf/ display left "p-value";
break after parameter/summarize suppress;
run;

ods _all_ close; /* Closing all ODS outputs statements*/

In the above example probf is a numeric variable within the across variable ‘test’. So in the output a period occurred when the break statement active. Eliminate this we add one more statement in the dataset Test2.
probf1=put (probf, pvalue6.); /* for converting numeric type to character*/

Generally we can say that the numeric variables within the across variable in REPORT procedure should make a period in the blank space and to avoid this convert numeric variables to character by using PUT function.



SAS with mySQL
Compiled by Soumya Gopinath


How to transfer the MySQL Databases named dbformo and dbformo_add to SAS datasets library names formoSQL and AddSQL respectively?

Solution:
libname libname ODBC datasrc= source user= user name password= password schema= database;

By using the procedure COPY we can copy the library formoSQL and AddSQL to our permanent SAS libraries FormoDM and FormoAdd respectively. Before executing the connection string add an ODBC Data source name in the current system, which should be the same as given in datasrc= option. The process,

1) Settings -> Control Panel ->Administrative Tools ->Data Source (ODBC)
2) Click on the Add button.
3) Select the driver for which you want to set up a data source (MySQL ODBC 3.51 Driver) and click Finish button.
4) Add required information in Connector/ODBC window. Click OK button. Then the process is completed.
VB and mySQL
Compiled by Soumya Gopinath

How will you connect a data entry application written in VB to mySQL ?

DRIVER= {MySQL ODBC 3.51 Driver};SERVER=server id; DATABASE=database name; UID=user name; PWD=password";

Wilcoxon Signed Rank test

Compiled by Sreedevi Menon

As part of the efficacy analysis of a recent Phase III study , it was planned to determine the significant difference in efficacy of treatments over the weeks. Each treatment group was analyzed separately. The paired t-test was employed to carry out the analysis on the parametric data.The Wilcoxon Signed Rank test was used for analysis of efficacy of treatments with respect to non-parametric data. The null hypothesis was that in the underlying population of differences among pairs the median difference is equal to 0. The alternate hypothesis may be one sided or two sided.

In SAS, this test is performed using the proc univariate procedure. Before applying the procedure, the difference between the value of parameter at the two time points that are to be compared (usually pre and post dose values) has to be computed. This difference is then defined in the “var” statement of the procedure. The syntax is as followed

ods output BasicMeasures= _A TestsforLocation= _B
proc univariate data= eff_data;
var diff;
run;
ods output close;

The output will contain p-value corresponding to Student’s t, Sign and Signed Rank tests. The p-value corresponding to the signed rank test will be considered. Further, For a 1-sided p-value, we would divide the 2-sided p-value by 2.The ‘ods output statement’ is used to extract descriptive statistics and the p value to two different datasets by using the as shown in the above example

Transpose macro
Compiled by Ajish K Mani

%macro trans(dsn=, outdsn=, vartran=, idtran=, bytran=, copytran=);
proc transpose data=&dsn out=&outdsn let;
var &vartran;
by &bytran;

%if &copytran ne %then %do;
copy ©tran;
%end;

%if &idtran ne %then %do;
id &idtran;
%end;
run;
%mend trans;

data input
input patno 1 sex $ 3 visit 5 weight 7-8 height 10-12;
datalines;
1 m 1 80 150
2 f 1 65 160
3 f 1 70 165
4 f 1 60 170
5 m 1 68 168
;
run;

proc sort data=input out=output;
by patno;
run;


%trans (dsn=output, outdsn=transpose(rename=(col1=Result)), vartran=weight height, bytran=patno);

data transpose;
set transpose;
label _name_ ="Parameter" ;
rename _name_=Parameter;
run;

25.7.07

Asthma Studies

For the analysis of any clinical trial on asthma inhalers, your efficacy parameters are most probably going to be related to the spirometry measures and will almost always include the following
FEV1 - Forced expiratory volume in 1 second
The FEV1 is the volume exhaled during the first second of a forced expiratory maneuver started from the level of total lung capacity.

PEF - Peak expiratory flow
Expiratory peak flow (PEF) is the maximum flow generated during expiration performed with maximal force and started after a full inspiration .

FVC - Forced expiratory vital capacity
The volume change of the lung between a full inspiration to total lung capacity and a maximal expiration to residual volume. Here are more details on Spirometry. Also check out GINA for more Asthma information

Blind Review

First of all the ICH definition - Blind Review is the checking and assessment of data during the period of time between trial completion (the last observation on the last subject) and the breaking of the blind, for the purpose of finalizing the planned analysis.


So how do we do it ? We look at the Clinical Protocol and create a Blind Review Criteria document which will list out all the conditions that needs to be checked against the data to make sure that there is no violations. For eg. if Visit 1 were to happen with in 15-20 days of the screening visit, then we compare the dates of screening and visit1 and if the difference falls below 15 and above 20, then boom we have a violation. Then we write a SAS program to check all those conditions and run it to create a protocol violation document.

Easily said. But to do it and to make sure that all the violations are caught is one hell of a task Johnny.
Hodges-Lehmann ∆

A parametric test, such as the t-test, compares the means of the two samples. A nonparametric method, such as the Wilcoxon Rank Sum Test compares the entire distributions of the two independent samples. The null hypothesis of the Wilcoxon Rank Sum test says the two samples can be viewed as a single sample from one population. The alternative hypothesis is that the first treatment group has a different different distribution (or location) than the second treatment group.

The treatment effect, denoted as ∆, is the difference between treatment groups. If parametric methods were used, means could be calculated for each treatment group, and a subtraction of the means can be used to estimate ∆. However, when the data are not normally distributed and the median value of the response variable of interest is calculated for each treatment group, the estimate of the difference in treatment groups is not as straightforward as subtracting one median from the other.

The difference in medians is estimated using the methodology of Hodges-Lehmann. It is a very simple approach. The following steps can be used to estimate ∆:

• form all possible differences between the first treatment group and the second treatment group, in the response variable of interest. For example, if there are 100 patients in each group then 10,000 (100*100) differences would be calculated.
• the estimator ∆ is the median of those 10,000 differences.

All this taken from this SUPER PAPER.
LOCF

In clinical trials, data are often collected over a period of time from participating patients. In many situations, however, analyses are only based on data from the last time point (the end of the study) or change from the baseline to the last time point. It is often the case that patients drop out before the completion of the study.

So the question arises on how to perform analysis of the last observations, which are defined as observations from the last time point for patients who completed the study and the last observations prior to the dropout for patients who did not complete the study.

An analysis based only on data from patients who completed the study is called a completers analysis. Although a completers analysis is sufficient in some situations, it is often more desirable to perform an all randomized subjects analysis.

The analysis based on all randomized subjects is usually referred to as an intention-to-treat (ITT) analysis. Regulatory agencies generally consider the ITT analysis as the primary analysis for evaluation of efficacy and safety in clinical trials with informative dropout.

When the dropout is informative, the target populations of a completers analysis and an ITT analysis are different. Suppose that the population of patients under certain treatment is stratified according to the time of the last observations; then the target population of a completers analysis is only the subpopulation of patients who completed the study under different treatments while the target populations of an ITT analysis include all the subpopulations under different treatments.

For the last observation carry-forward (LOCF) analysis based on ITT population, the last observations are carried forward to the last time point for patients who dropped out. The LOCF analysis treats the carried-forward data as observed data at the last time point. Therefore when the dropout is informative, the LOCF analysis may introduce biases to the statistical inference, which has been speculated upon by the Food and Drug Administration (FDA) it is still unknown whether or not the LOCF test is asymptotically correct

Here is a macro that might help you with LOCF

24.7.07

Research Capital

An analysis of published papers in the field of medical research has found that Thiruvananthapuram accounts for 64 percent of the total papers published in the state. Something that make Kreara proud about our location

19.7.07

Concomitant Medications

Did you know we could code them with out paying 7 lakhs to Uppsala.
Check this out

4.7.07

Area Under Curve (AUC)

In the field of pharmacokinetics, the area under the curve (AUC) is the area under the curve in a plot of concentration of drug in plasma against time.

In real-world terms the AUC (from zero to infinity) represents the total amount of drug absorbed by the body, irrespective of the rate of absorption. This is useful when trying to determine whether two formulations of the same dose (for example a capsule and a tablet) release the same dose of drug to the body.


AUC becomes useful for knowing the average concentration over a time interval, AUC/t. Also, AUC is referenced when talking about elimination.
The amount eliminated by the body = clearance (volume/time) * AUC (mass*time/volume).

Another application that we recently found is when we try to establish the equivalence of two asthma formulations and their superiority over placebo. Here are some links if you

a. want to learn how we can use integration to find the AUC
b. A small SAS macro to calculate AUC using trapezoidal rule
c. Use proc expand to find out the AUC


2.7.07

Wilcoxon rank-sum test

The Wilcoxon rank-sum test is a non-parametric analog of the two-sample t-test. It is based on ranks of the data, and is used to compare location parameters, such as the mean or median, between two independent populations without the assumption of normally distributed data.


DATA RNKSM;
INPUT TRT $ PAT SCORE @@;
DATALINES;
SER 2 0 SER 3 2 SER 5 3 SER 6 3
SER 8 -2 SER 10 1 SER 12 3 SER 14 3
SER 16 -1 SER 17 2 SER 20 -3 SER 21 3
SER 22 3 SER 24 0 SER 26 2 SER 27 -1
PBO 1 3 PBO 4 -1 PBO 7 2 PBO 9 3
PBO 11 -2 PBO 13 1 PBO 15 0 PBO 18 -1
PBO 19 -3 PBO 23 -2 PBO 25 1 PBO 28 0
;

PROC NPAR1WAY WILCOXON DATA = RNKSM;
CLASS TRT; VAR SCORE;
TITLE1 'The Wilcoxon Rank-Sum Test';
RUN;

1.7.07

Van Elteren's test

You can think of van Elteren's test as analogous to an analysis of variance with a blocking factor. One common use of the van Elteren test is with clinic as the stratification variable in a multicenter clinical study. van Elteren's test is used in lieu of randomized blocks ANOVA with clinics as blocks. In the case of a geographically distributed study we could use this test with country as a blocking factor

Here is how we could perform the test in SAS

data a;
input blocks treatmnt consump @@;
datalines;
1 1 236 1 2 255
2 1 183 2 2 179 2 2 193
3 1 115 3 1 128 3 2 132
4 1 61 4 1 70 4 1 79 4 2 67 4 2 84 4 2 88
;

proc freq;
tables blocks * treatmnt * consump / cmh2 scores=modridit noprint;
run;