Hello,
I am using this sample note by SAS to loop through a set of character values. The original macro loop works fine but not sure why mine does not.
DATA METRICS;
LENGTH MT $25;
INPUT MT ;
CARDS;
TOT_COMP_PGM
REG_MEM
BIO_SCREEN
FAX_MAIL_BIO_SCREEN
HEALTH_ASSESS
;
RUN;
PROC SQL NOPRINT;
SELECT MT
INTO :MACVAR_METRICS SEPARATED BY ','
FROM METRICS
;
QUIT;
%PUT &MACVAR_METRICS;
%MACRO _LOOP_TO_TRANSPOSE_DATASETS(values);
%let count=1;
%let value=%qscan(&values,&count,%str(,));
/* Loop through the total number of values */
%do %while(&value ne);
%put &value;
%let count=%eval(&count+1);
%let value=%qscan(&values,&count,%str(,));
%end;
%MEND _LOOP_TO_TRANSPOSE_DATASETS;
/* %STR is used to mask the commas from the macro compiler when */
/* the macro %LOOP is called. */
%_LOOP_TO_TRANSPOSE_DATASETS(&MACVAR_METRICS)
I am getting this error -
SYMBOLGEN: Macro variable MACVAR_METRICS resolves to TOT_COMP_PGM,REG_MEM,BIO_SCREEN,FAX_MAIL_BIO_SCREEN,HEALTH_ASSESS
ERROR: More positional parameters found than defined.
I tried using different ways to invoke the macro but I still keep getting an error -
%_LOOP_TO_TRANSPOSE_DATASETS(value=&MACVAR_METRICS)
46 TOT_COMP_PGM,REG_MEM,BIO_SCREEN,FAX_MAIL_BIO_SCREEN,HEALTH_ASSESS
__________
180
ERROR: All positional parameters must precede keyword parameters.
ERROR 180-322: Statement is not valid or it is used out of proper order.
I would appreciate any help.
Thanks,
saspert.