Hello, I am using the SQL procedure to create macros as written below. When I write the code below, macros are created as desired and work as global macros outside the SQL procedure. proc sql noprint;
select quote(strip(diagnosis)) into :PregnanacyDiag separated by ',' from PregnancyDiag;
quit; %put &PregnanacyDiag; /*appropriate code is written to the log*/ I am using the above procedure many times to create macro variables containing quoted strings of code from numerous datasets which contain procedural, diagnostic, and drug codes. Accordingly, it makes sense to convert this code into a macro. I attempted to do so as show below. %macro makemac(var,macname,dataset);
select quote(strip(&var)) into :&macname separated by ',' from &dataset;
%mend;
proc sql noprint;
/*Diaphragm Lookup Codes*/
%makemac(procedure,ProcMAC_Diaphragm,DiaphragmProc);
%makemac(ndc,NdcMAC_Diaphragm,DiaphramNDC);
/*Implant Lookup Codes*/
%makemac(diagnosis,DiagMAC_Implant,ImplantDiag);
%makemac(procedure,ProcMAC_Implant, ImplantProc);
%makemac(ndc,NdcMAC_Implant,ImplantNDC);
quit; %put &ProcMAC_Diaphragm; I expected that the SQL procedure would run as normal with the '%makemac' macro inserting appropriate syntax for select statements for each line of code. When I run the program, the log appears normal. I used the 'symbolgen' option, and it shows the appropriate values replaced for each line of macro code. But when I try to use the '%put &(macro name)' statement, it does not write the string of quoted code to the log I expected, and I receive instead the warning below. "WARNING: Apparent symbolic reference PROCMAC_DIAPHRAGM not resolved." If anyone could offer suggestions to fix this, I would greatly appreciate it. I am using this code many times. When I hard code it, it works as desired. But streamlining the code as a macro makes more sense to me. Also, I'd just like to understand the error. Thanks, Ted
... View more