expglm Expand a GLM model specification from bar notation expglm

SAS Macro Programs: expglm

$Version: 1.0 (12 Feb 2006)
Michael Friendly
York University


The expglm macro ( [download] get expglm.sas)

Expand a GLM model specification from bar notation

The expglm macro expands shorthand GLM/GENMOD model notation using the | and @ symbols to a blank-separated list of main effect and interaction terms. Useful for macros which need to deal with the terms separately, or for procs which do not allow | notation.

Usage

The macro argument should be a string of legal SAS variable names separated by blanks for separate model terms, optionally including the | and @ symbols. The macro returns an expanded string from the macro argument, for example

  %let model = %expglm(A|B|C);

Examples

  %expglm(A|B) --> A B A*B;
  %expglm(A|B A|C) --> A B A*B C A*C;
  %expglm(A|B|C@2) --> A B A*B C A*C B*C;

Limitations

Doesn't check syntax, or respond gracefully to ill-formed models.

No blanks are allowed inside any term, certainly not inside ()

Doesn't handle nested effects properly, but this is beyond what can be done using pure macro processing.

  A|B(A) should --> A B(A)
  A(B)|C(D) should --> A C A*C(B*D)

See also

lastword Return the last word from a delimited list of words
vexpand Expand abbreviated variable lists