I've tried restarting my SAS program and computer and this macro is just not running, no errors, nothing - just the code is in the log... I'm probably missing the simplest thing... am I calling in the macro variables correctly? I know sometimes you utilize a period so I thought that would be appropriate for the second macro variable.... Thanks for your help in advance!
%macro DX(no=, var=);
proc sql;
create table dx_&no as
select a.admission_id, b.DIAG_DESC
from adms_5 a left join table.DIAGNOSIS b on a.&var.=b.DIAG_CD;
quit;
%DX(no=1, var=DIAG_CD_1);
%DX(no=2, var=DIAG_CD_2_1);
%DX(no=3, var=DIAG_CD_2_4);
%mend DX;
@accintron wrote:
I've tried restarting my SAS program and computer and this macro is just not running, no errors, nothing - just the code is in the log... I'm probably missing the simplest thing... am I calling in the macro variables correctly? I know sometimes you utilize a period so I thought that would be appropriate for the second macro variable.... Thanks for your help in advance!
%macro DX(no=, var=);
proc sql;
create table dx_&no as
select a.admission_id, b.DIAG_DESC
from adms_5 a left join table.DIAGNOSIS b on a.&var.=b.DIAG_CD;
quit;
%DX(no=1, var=DIAG_CD_1);
%DX(no=2, var=DIAG_CD_2_1);
%DX(no=3, var=DIAG_CD_2_4);
%mend DX;
Try:
%macro DX(no=, var=); proc sql; create table dx_&no as select a.admission_id, b.DIAG_DESC from adms_5 a left join table.DIAGNOSIS b on a.&var.=b.DIAG_CD; quit; %mend DX; %DX(no=1, var=DIAG_CD_1); %DX(no=2, var=DIAG_CD_2_1); %DX(no=3, var=DIAG_CD_2_4);
Attempting to use the macro in the defining code is a path to madness and unexpected results.
I would also suggest shutting down SAS and restarting as you may have created an very unstable situation.
You defined the macro, you never told SAS to execute the macro after it has been defined.
These go after %MEND;
%DX(no=1, var=DIAG_CD_1)
%DX(no=2, var=DIAG_CD_2_1)
%DX(no=3, var=DIAG_CD_2_4)
Woops! Thanks!! Yes, that worked and I had to use . after my &no macro variable.
@accintron wrote:
I've tried restarting my SAS program and computer and this macro is just not running, no errors, nothing - just the code is in the log... I'm probably missing the simplest thing... am I calling in the macro variables correctly? I know sometimes you utilize a period so I thought that would be appropriate for the second macro variable.... Thanks for your help in advance!
%macro DX(no=, var=);
proc sql;
create table dx_&no as
select a.admission_id, b.DIAG_DESC
from adms_5 a left join table.DIAGNOSIS b on a.&var.=b.DIAG_CD;
quit;
%DX(no=1, var=DIAG_CD_1);
%DX(no=2, var=DIAG_CD_2_1);
%DX(no=3, var=DIAG_CD_2_4);
%mend DX;
Try:
%macro DX(no=, var=); proc sql; create table dx_&no as select a.admission_id, b.DIAG_DESC from adms_5 a left join table.DIAGNOSIS b on a.&var.=b.DIAG_CD; quit; %mend DX; %DX(no=1, var=DIAG_CD_1); %DX(no=2, var=DIAG_CD_2_1); %DX(no=3, var=DIAG_CD_2_4);
Attempting to use the macro in the defining code is a path to madness and unexpected results.
I would also suggest shutting down SAS and restarting as you may have created an very unstable situation.
Thank you! Yes, definitely will restart SAS fresh now that the code is working appropriately!
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.