Documentation

12.10 Code syntax, control flow, Y and scope

COD01 parses abbreviated code. COD02 balances IF/THEN/ELSE/ENDIF and DO WHILE/ENDDO. COD07 requires Y in $ERROR for PREDPP or $PRED. COD09 validates variable names. COD10 enforces block scope: no EPS in $PK, DADT only in $DES, and A(n) not in $PK.

Syntax is the first boundary

An unbalanced block can make later symbol findings misleading. Fix the smallest syntax problem first and rerun. Preserve indentation as a review aid, but remember NONMEM semantics come from tokens/blocks, not indentation alone.

Y is the observation model

Defining IPRED or W does not define the likelihood observation. Trace every branch to ensure Y receives a value. A parser can find an assignment somewhere while scientific path coverage still requires tests.

Block legality

Variables available in $ERROR may be illegal in $PK; state derivatives belong to $DES. Scope violations often reveal code pasted between model types without full adaptation.

Review paths, not just lines

Make a branch table for every IF/ELSE chain: condition, variables defined, value assigned to Y, and reachable record types. Test at least one dataset row for each branch. Loops need the same treatment, including the zero-iteration case. COD02 can recognize balanced tokens while a branch remains unreachable or assigns an unintended formula. COD09 also protects the lexical interface: a legal-looking rename must be propagated to later code and $TABLE. After static review, compile with NM-TRAN because its parser and version-specific rules remain authoritative for execution.

Common mistakes

  • Fixing indentation but not missing ENDIF.
  • Defining Y only on one branch.
  • Using EPS in PK to emulate variability.
  • Renaming a reserved variable without updating all uses/tables.

Checklist

  • Resolve COD01/COD02 before downstream code findings.
  • Trace Y assignment through every condition.
  • Review special-variable legality by block.
  • Rerun parse and execution tests.

Further reading

See model statements/branches, symbol flow and checker limits.