|
I want to find a way to create a dataset within a macro definition.
I have tried the following:
%macro test;
data categories;
infile datalines dlm=',' dsd;
length category $55;
input category $ _group _order;
datalines;
"Genotype consent",1,1
" Obtained",1,2
" Not obtained",1,3
"Genotype sample status",2,4
" Collected and evaluated",2,5
" Collected but not evaluated ~(due to withdrawn consent)",2,6
" Collected but not evaluable",2,7
" Not collected",2,8
;
run;
%mend;
%test;
This generates the following error:
ERROR: The macro TEST generated CARDS (data lines) for the DATA step,
which could cause
incorrect results. The DATA step and the macro will stop
executing.
Looking at the sas support I found the following information on this:
"A macro definition cannot contain a CARDS statement, a DATALINES
statement, a PARMCARDS statement, or data lines. Use an INFILE
statement instead."
Unfortunately our systems require code to be wrapped in a macro for
execution, and I would like the code to be portable. Does anyone know
of a way around this??
Thanks in advance
|