"Tip of the Week #8 - April 16, 2002" - Sequential numbering in a TABLE

From: William Bachman Date: April 16, 2002 technical Source: cognigencorp.com
From: "Bachman, William" Subject: [NMusers] "Tip of the Week #8 - April 16, 2002" - Sequential numbering in a TABLE Date: Tue, 16 Apr 2002 13:54:07 -0400 Tip of the Week #8 - Sequential numbering in a NONMEM TABLE Frequently, patients are numbered in any manner of non-sequential ways and the modeler may want a sequential patient numbering, for example, to use in plotting programs. Also, it may at times be useful to have a number for a record within an individual or a sequential number for all records in a data set (e.g. to aid in tracking down specific outliers). The code below is one way to obtain all three of these goals: 1. SID, sequential individual number 2. INDR, record number within an individual 3. INDX, sequential number of all records in a data file Simply add the code below to the $PK section of your control stream and the variable names to the $TABLE record. Note this code DOES NOT work with POSTHOC or FOCE, so as a work-around you could to do this in a separate METHOD=0 run (without POSTOC) if you are using either POSTHOC or FOCE methods. The desired columns from this run could then be appended to your table from the POSTHOC or FOCE run. [See NONMEM Users Guide V, p.78 for a description of NEWIND.] $PK ;TO SEQUENTIALLY NUMBER INDIVIDUALS IF(NEWIND.EQ.0) SID=1 IF(NEWIND.EQ.1) SID=SID+1 ;TO NUMBER RECORDS WITHIN AN INDIVIDUAL IF(NEWIND.EQ.1.OR.NEWIND.EQ.0) INDR=1 IF(NEWIND.EQ.2) INDR=INDR+1 ;TO NUMBER ALL RECORDS IN A DATAFILE IF(NEWIND.EQ.0) INDX=1 IF(NEWIND.EQ.1) INDX=INDX+1 IF(NEWIND.EQ.2) INDX=INDX+1 $ESTIMATION MAXEVAL=9999 PRINT=5 METHOD=0 ;DON'T USE POSTHOC or FOCE!!! $TABLE ID TIME DV AMT SID INDR INDX FILE=TABLE.TAB NOPRINT [Generic Disclaimer: Verify that this code or any other code you receive from an outside source works with YOUR DATA.] NONMEM Coding Challenge #2: 1. Why doesn't this code generate the correct values for SID & INDX with Posthoc or FOCE? 2. How would you code a general method that works for M=0/M=0 Posthoc/M=1? Send your solutions to nmconsult@globomaxnm.com. Best solution will appear as a future tip of the week. Previous tips may be found in the NONMEM Repository@GloboMax: ftp://ftp.globomaxnm.com/Public/nonmem/tips/ ***************************************************************** If you have a "tip" or a better way to do things, by all means, feel free to post them! One of the reasons for doing this (other than good PR for GloboMax), is to stimulate discussion. We at GloboMax can learn from your experience as well. Do you have a "tip" you would like to share, but would prefer to remain anonymous? If so, you may forward it to us and your identity will be withheld. Distribution as a "Tip of the Week" will be at the discretion of nmconsult@globomaxnm.com. ***************************************************************** nmconsult@globomaxnm.com GloboMax LLC 7250 Parkway Drive, Suite 430 Hanover, MD 21076 Voice: (410) 782-2205 FAX: (410) 712-0737