Date: Tue, 20 Aug 1996 14:36:37 -0500
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Robert Agostinelli
Subject: Using a variable's values to create SAS source code
I have a SAS dataset ( with 1000's of observations ) that has 4
Patient Age Sex Condition
------- --- --- ------------------------------------------
1 21 M If age > 12 and age < 26
2 63 F If age < 18
3 45 M If age > 18 and sex = M
The condition variable is different for each observation. I have
already written the SAS code that parses the condition into three
variables: a low age range, a high age range, and the sex condition.
In reality, the condition also contains criteria for race and other
parameters as well.
However, I am looking for a cleaner solution than having to parse the
text. I would like to be able to use the value of the condition
variable as part of the SAS program that evaluates the observation as
pass/fail. To do this, I know that macros are required to build
dynamic SAS code.
Therefore, I want to create a 5th variable that flags whether or not
the current obs. meets it's own condition.
For example, patient 1 would pass it's own condition, and the flag
would be set to 'pass'. Patient 2 would fail since the patient is 63
years old and the condition to pass requires them to be less than 18.
Patient 3 would pass.
Does anyone know what the SAS macro code should be to perform this
Thanks for your help.