From: "Munsanje, Elliot [CNTUS]" EMunsanj@CNTUS.JNJ.COM
Subject: [NMusers] SAS program or SAS macro to prepare NonMem ready data
Date: Tue, December 7, 2004 3:38 pm

Dear NMusers: 
I am new to using NonMem. Does anyone have a SAS code that formats a
data set to be used in NonMeM. If not, which software is recommended
to make this ready-to go NonMem data.

Elliot
_______________________________________________________

From: "Nick Holford" n.holford@auckland.ac.nz
Subject: Re: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Tue, December 7, 2004 3:59 pm 

Elliot,

There is no such thing as automatic, ready to go preparation of NONMEM data files.
The structure and content of a NONMEM data file is intimately tied up with the exact
NONMEM model that will be run.

Typically I get data from SAS or other databases in a plain text ASCII format and
use awk to format it for NONMEM. This allows me to automate the creation of NONMEM
data sets that are fine tuned for different models that I want to try.

Keep dreaming :-)

Nick

--
Nick Holford, Dept Pharmacology & Clinical Pharmacology
University of Auckland, 85 Park Rd, Private Bag 92019, Auckland, New Zealand
email:n.holford@auckland.ac.nz tel:+64(9)373-7599x86730 fax:373-7556
http://www.health.auckland.ac.nz/pharmacology/staff/nholford/
_______________________________________________________

From: mark.e.sale@gsk.com
Subject: Re: [NMusers] SAS program or SAS macro to prepare NonMem readydata 
Date: Tue, December 7, 2004 4:16 pm

Elliot,   

I have an Excel macro (I know Nick, real pop kineticists use Splus
not Excel macros) that seems to work pretty well, and is pretty
general.  I'm happy to share, but won't use the bandwidth to send to out. 
Contact me if you want it.  Of course, undocumented, unvalidated, not
part 11, CFR 21 compliant etc.  But, it only does the work, you have
to know what you want the data set to look like.  As Nick points out,
the structure of the data set is closely related to the model, so you
typically need multiple data sets for the many model in an analysis. 



Mark Sale M.D.
Global Director, Research Modeling and Simulation
GlaxoSmithKline
919-483-1808
Mobile 
919-522-6668
_______________________________________________________

From: "Munsanje, Elliot [CNTUS]" EMunsanj@cntus.jnj.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Wed, December 8, 2004 10:01 am 

Nick: 
I think that is within the capabilities of SAS. A SAS macro may be customized
to accomodate this intimate tie of structure and content of a NONMEM file to
the model. Already this is done using excel macros. By the number of responses,
may be very few people use SAS to generate NONMEM data sets. May be this is due
to specialization either in programming or Modeling and rarely a combination
of these skills. 

Elliot 
_______________________________________________________

From: mike.k.smith@pfizer.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Wed, December 8, 2004 10:38 am 

Elliot,
 
I think Nick's point is valid.  The way that dosing histories and regimens are
coded within the dataset and given the flexibility that that allows, coming
up with a "catch-all" SAS macro to accommodate all possible data structures
would take some effort.  Using macro variables and switches it would certainly
be possible to come up with a simple SAS macro to cope with simple cases.  I
suspect that there are many people within pharma-companies using SAS to prepare
NONMEM datasets, but where these are either bespoke pieces of code for the
given situation or perhaps they are considered intellectual property and not
available for dissemination.
 
Regards,
Mike 
_______________________________________________________

From: From:   "Bonate, Peter" pbonate@ilexonc.com
Subject: RE:  [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Wed, December 8, 2004 11:25 am 

The SAS code to generate a NONMEM data set is actually very easy.
 
Suppose you have a data set (called DATA) sorted by id, time with variables
ID TIME CONC DOSE.  Dose can occur on every record or not as long as it has
a value for the first record for each subject.  Then you can generate the
data within a data step.  Here is a sample code for an oral dose given every
24 hours with observations at steady-state.  Each subject has data collected
on one occasion.
 
proc sort data=data; by id time; run; quit;
data nonmem;
    set data;
    by id;
    if first.id then do;
        evid = 1;
        mdv = 1;
        ii = 24;
        ss = 2;
        dv = 0;
        cmt = 1;
        amt = dose;
        output;
        amt = .;
        ii = .;
        ss = .;
        evid = 0;
        dv = conc;
        if dv = . then mdv = 1; else mdv = 0;
        cmt = 2;
    end;
    else do;
        amt = .;
        ii = .;
        ss = .;
        evid = 0;
        dv = conc;
        if dv = . then mdv = 1; else mdv = 0;
        cmt = 2;
    end;
run; quit;
 
        
 
Now suppose you have data on multiple occasions coded by a new variable 'OCC'.  The
code would be the same except for the following:

1.) Change proc sort data=data; by id time; run; quit; to proc sort data=data; by id occ time; run; quit;
2.) change  if first.id then do; to     if first.occ then do;
 
You may need to tweak it a little bit for specific cases but this should do the trick.
 
Pete Bonate

Peter L. Bonate, PhD, FCP
Director, Pharmacokinetics
ILEX Oncology
4545 Horizon Hill Blvd
San Antonio, TX 78229
phone: 210-949-8662
fax: 210-949-8219
email: pbonate@ilexonc.com
_______________________________________________________

From: "Wang, Yaning" WangYA@cder.fda.gov
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem readyda ta 
Date: Wed, December 8, 2004 11:30 am

I almost exclusively use SAS to generate all kinds of NONMEM data set. I believe
Splus can do the work too. But the sort function in Splus is too slow for large
dataset. Many other softwares (Excel, Systat, Awk, etc.) can do the work. It is
only a matter of how familiar someone is with a specific software. 
 
Yaning Wang, PhD 
Pharmacometrician, OCPB, FDA 
_______________________________________________________

From: "Sam Liao" sliao@pharmaxresearch.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data
Date: Wed, December 8, 2004 12:04 pm

Hi Elliot:

 

We used SAS in NONMEM data preparation.  But each SAS program has to adapt
to the structure of available SAS data sets and the nmv model of the study.  

I may have a SAS program that you can use as a template to develop a SAS
program for your study.  But it will require some experience in SAS programming. 

Please give me a call if you need a template.

Sam Liao
PharMax Research

732-3029550
_______________________________________________________

From: Michael.J.Fossler@gsk.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data
Date: Wed, December 8, 2004 12:08 pm

Although I am sure that vB and SAS do a fine job of building NM datasets, if
you are a new user looking to develop some programming skills in this area,
I would recomend that you give S-plus (or its open-source version, R) a serious
look. S was design to perform data manipulation, particularly data arranged in
columns. The advantage of this data vector orientation is that there are many
simple "one-step" commands in S+ that will do what many lines of a traditional
programming language (where you might need many for-next loops) can accomplish. 

This is just my perception, but it seems to me that far too many modelers still
build datasets by hand in Excel, particularly in small companies or in academia
where there aren't SAS programmers for hire. Not only is this prone to error, but
it's way too much work!!  If you are new to population PK, take the time to learn
a tool to help you with this important step - it will pay off quickly. 



Mike
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michael J. Fossler, Pharm. D., Ph. D., F.C.P.
Principal Clinical Pharmacokineticist
Clinical Pharmacokinetics, Modeling & Simulation
GlaxoSmithKline
(610) 270 - 4797
FAX: (610) 270-5598
Cell: (443) 350-1194
Michael_J_Fossler@gsk.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
_______________________________________________________

From: "Leonid Gibiansky" leonidg@metrumrg.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data  
Date:  Wed, December 8, 2004 12:14 pm 

Just checked: S+ 6.1 Release 1 for Windows (2 Gig processor) took 3 sec to sort
1 million random numbers, 12 sec to sort 1 million character variables (the same
numbers transformed to character variables)

Not too bad: never had problems with data creation in S+

Leonid 
_______________________________________________________

From: "Sam Liao" sliao@pharmaxresearch.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data
Date: Wed, December 8, 2004 12:39 pm 

Hi Yaning:

Do you mind if I ask your opinion from regulatory stand point?

I am not sure how we can be sure the integrity of the data when
other softwares were used in nmv data preparation.   

For NONMEM analysis which will be a part of regulatory submission, SAS
can provide a log file that keeps track of all the data manipulation
and derivation.

Sam Liao

PharMax Research
_______________________________________________________

From: "Beasley, Bach Nhi t" BEASLEYN@cder.fda.gov
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Wed, December 8, 2004 12:45 pm 

HI Elliot,
I use SAS to format datasets for Nonmem.  There are a few lines that I consistently
use, but I have not worked with one dataset yet that allowed me to reuse an entire
code.  These lines really won't save you any time, but you can contact me if you'd
like.  In addition to what's already been mentioned, another problem is that datasets
are set up in so many different ways and can be inconsistent within themselves (different
formats used within one column) that I've always had to write a separate code for each
NM dataset.  Not to be cynical, but I just don't see it happening in the near future. 
Good luck!
 
On another note, my personal bias is to stick with programs like SAS, SPlus, etc.. for
your programming since these programs leave you a "string" as opposed to cutting and
pasting in programs like Excel where mistakes have a greater potential to happen.
 
Nhi Beasley, Pharm.D.
Pharmacometrics 
FDA
beasleyn@cder.fda.gov 
_______________________________________________________

From: "Wang, Yaning" WangYA@cder.fda.gov
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Wed, December 8, 2004 1:34 pm

First of all, I want to clarify that all my posts here only reflect
my personal opinion. 
 
As far as I know, there is no regulatory preference for any commercial
software for data manipulation. On the other hand, it is a good practice
to use softwares that can keep track of all the data manipulation steps
so that we can easily reproduce the results or make further changes. SAS
may be the most popular software for data manipulation here in FDA since
all the data files are submitted as SAS transport files. But some of my
colleagues use S+ because they are more familiar with S+. Also some of
my colleagues use a program called JMP. 
 
Leonid:
My earlier comment on S+ sort function was based on my experience with S+ two
years ago on S+2000 (bound with TS2). I was trying to sort a large simulated
data frame based on two columns (ID TIME). It was much slower compared with
SAS at that time. Maybe I was not using the most efficient command or S+ 6.1
improves this function. Anyway, I am more comfortable with SAS. 
_______________________________________________________

From: "Chapel, Sunny" Sunny.Chapel@pfizer.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Wed, December 8, 2004 2:03 pm 

I use SAS and Splus for Nonmem datasets, but I just want to point out that
WinNonlin has some functionality for Nonmem data creation.  (I don't know how
good it is, though.)
 
Splus is convenient but it doesn't handle large datasets very well because of
its notorious "memory leak" problem.  In other words, Splus keeps copies of
intermediate datasets during calculation in the memory until it is sure that
they are unnecessary. No loops with large objects! When Splus shows the "insufficient
dynamic memory" message, the only way to be able to use Splus is to quit Splus
and restart it. 
 
I'm a big fan of Splus, but I tend to use SAS more and more for data manipulation
as the datasets I deal with become larger and larger.  If I were new and needed to
learn how to create Nonmem datasets, I would stick with SAS. 
 
I also think that the dream of automating Nonmem data creation won't come true soon.
 
Sunny Chapel, PhD
Clinical PK/PD
Pfizer Ann Arbor Laboratory
Sunny.Chapel@Pfizer.com 
_______________________________________________________

From: "Nick Holford" n.holford@auckland.ac.nz
Subject: Re: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Wed, December 8, 2004 2:04 pm

Elliot,

I am sure SAS (or almost any other programming language) can be used to write code
to format data for NONMEM. However, as several people have pointed out their is no
single piece of code that can do this for any input. 

There are many things that I do while formatting data for NONMEM -- this includes
consistency checking (e.g. are weights in a reasonable range?), putting out error
messages for invalid data (e.g. positive concentration of drug before any dose has
been given), transformation of values (e.g. some data sets have weights in both kg
and pounds [and if one is lucky a units indicator too!]), making decisions based on
all the records for a given individual (e.g. dosing records are supplied but no conc
records so I drop all these records from the NONMEM dataset because they add nothing
to a PK analysis).

In addition to these data driven needs there are model specific items that need to
be put in the data set e.g. CMT items depend on the model structure, additional
records are required to initialize differential equations.

IMHO the programming challenges for dealing with real NONMEM data sets and
non-trivial models (i.e. more than simple PK) demand the NONMEM analyst either
writes his/her own data formatting code or works with someone with these skills.

The ability to automate data formatting (and therefore demonstrate exactly how
original data is transformed) is an essential part of any quality based NONMEM
analysis. Manual manipulation of data items in Excel should be discouraged.

Nick
--
Nick Holford, Dept Pharmacology & Clinical Pharmacology
University of Auckland, 85 Park Rd, Private Bag 92019, Auckland, New Zealand
email:n.holford@auckland.ac.nz tel:+64(9)373-7599x86730 fax:373-7556
http://www.health.auckland.ac.nz/pharmacology/staff/nholford/
_______________________________________________________

From: david_john.garbutt@pharma.novartis.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Thu, December 9, 2004 9:53 am 

Hi, 

I think the issue is more subtle that this refutation purports to show. 

The way SAS (in the data step) processes data means that it generally needs
an amount of memory proportional to the size of one observation. 
The same SAS program will run on any size of dataset (the limit is the disk space
you have). S-Plus (and other packages keeping data in memory, like minitab ;-))
need memory proportional to the size of the whole dataset. 
Therefore they will not be able to run a given program for some finite data size. 
As it happens this critical size is these days larger. But it still exists and
it can be a practical problem. 
And it is therefore a reason to choose SAS over others. 

regards, 

Dave Garbutt 

http://public.xdi.org/=djg  
_______________________________________________________

From: "Bachman, William (MYD)" bachmanw@iconus.com
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data 
Date: Thu, December 9, 2004 10:22 am

I don't really see a need to choose one program over the other, at least
not in an all or none sense.  In the realm of dataset preparation, SAS, in
my opinion, is superior to S-Plus. It is the overall industry standard, it
does handle large data sets better than S-Plus and statisticians and data
management people have a long history with it.  On the down-side, $A$ gouges
the industry on a yearly basis.
 
In favor of S-Plus, it has a strong foothold in the population analysis niche
primarily because it has fabulous graphics capabilities.  On the Windows platform,
you buy it once and you own it (as long as you don't want or need to upgrade).  The
language is very powerful but the learning curve is VERY steep.  But like SAS you
can script it to automate procedures and if you have an in-house S-Plus guru - don't
let him leave!  (S-Plus scripts perform the same function as SAS macros with respect
to documentation of process).
 
Bottom line, use the best tool for the particular problem. 
_______________________________________________________

From: "Leonid Gibiansky" leonidg@metrumrg.com 
Subject: RE: [NMusers] SAS program or SAS macro to prepare NonMem ready data
Date: Sat, December 11, 2004 12:23 am

Do not get me wrong: I am not arguing against SAS or for S+: I think,
this is a matter of preference and depends on the problems that you
need to solve. I was commenting on a particular question: data set
creation for PK/PD modeling. In this setting, S+ memory problems/limitations
do not manifest itself. Even if they would, this is not related to the
performance of the sort function but rather to memory management. For data
set creation, data diagnostics and NONMEM model output diagnostics  S+ (or R)
should be adequate. If you try to analyze results of 1000 simulations of the
trail with 1000 patients you better use SAS: most likely, S+ will not be
able to handle it.
 
To me, the major limitation of SAS is cost while S+ is not expensive and R is free.
 
Leonid 
_______________________________________________________