Hello everyone,
I posted the following code for another question
,thanks to @Rick_SAS I solved that Discussion. In that discussion, I realized I'm getting some errors
I just don't understand even though macro resolves Variable3 and Variable4 why it doesn't resolve the Variable1.
Can someone help me that how can I build proper structure?
If you execute the code you can see the errors in the log.
Data Have;
Length Target 8 Variable1 8 Variable3 8 Variable4 8 ;
Infile Datalines Missover;
Input Target Variable1 Variable3 Variable4 ;
Datalines;
0 -0.435409602 0.1111702173 -0.375361259
0 -0.435409602 0.9767642068 -0.375361259
1 -0.435409602 0.9767642068 -0.375361259
0 -0.435409602 0.9767642068 -0.375361259
0 0.8432328141 0.9767642068 -0.566274869
1 -0.435409602 0.9767642068 0.5257570782
0 -0.202340531 0 0.5257570782
0 -0.435409602 0 0.5257570782
1 0.3610487663 -1.119484453 0.5257570782
1 0 0 0.1876969043
0 -0.435409602 -0.82913977 -0.566274869
0 -0.435409602 -0.82913977 0.1876969043
1 0.3610487663 0.9767642068 -0.199600942
0 0.8432328141 0 -0.199600942
0 -0.202340531 0.9767642068 -0.375361259
;
Run;
%Macro Fake_Table;
Data Result_Append;
Length Dataset $ 32 Variable $ 9 Variable2 8;
Run;
Proc Sql; Delete From Result_Append;
%Mend Fake_Table;
%Macro Test(Var);
Ods Output ResponseProfile=Res_&Var. Association=Roc_&Var. ParameterEstimates=Err_&Var.;
PROC LOGISTIC DATA=Have NameLen=32 PLOTS(ONLY)=ALL;
MODEL Target (Event = '1')=&Var. /SELECTION=NONE LINK=LOGIT;
RUN;
QUIT;
Ods Output Close;
Data Err2_&Var.(Keep=Variable StdErr Dataset Rename=(StdErr=Variable2));
Length Dataset $ 32;
Set Err_&Var.;
Where Variable="&Var.";
If Variable="&Var." then Variable="StdErr_";
Dataset="&Var.";
Run;
Data Roc2_&Var.(Keep=Label2 nValue2 Dataset Rename=(nValue2=Variable2 Label2=Variable));
Length Dataset $ 32;
Set Roc_&Var.;
IF Label2="Somers' D" Or Label2="c";
If Label2="c" then Label2="Roc_";
If Label2="Somers' D" then Label2="Gini_";
Dataset="&Var.";
Run;
PROC SQL;
Create Table Append_&Var. As
Select * From Roc2_&Var.
Outer Union Corr
Select * From Err2_&Var.;
QUIT;
PROC APPEND Base=Result_Append Data=Append_&Var.;
Run;
%Mend Test;
%Macro Test_Loop;
%let i=1;
%do %while(%scan(&Variable.,&i.,%str( ))~=);
%Test(%scan(&Variable.,&i.,%str( )));
%let i=&i.+1;
%end;
%mend;
%Let Variable=Variable1 Variable3 Variable4;
%Fake_Table;
%Test_Loop;
Thank you
Put a QUIT statement to end the PROC SQL step:
Proc Sql; Delete From Result_Append; QUIT;
The problem is that PROC SQL is an interactive procedure. Therefore it is still running when the ODS OUTPUT statement is encountered, which leads to the error. For more information about ODS statements and interactive procedures, see "SAS Tip: Put ODS statements inside procedures."
Put a QUIT statement to end the PROC SQL step:
Proc Sql; Delete From Result_Append; QUIT;
The problem is that PROC SQL is an interactive procedure. Therefore it is still running when the ODS OUTPUT statement is encountered, which leads to the error. For more information about ODS statements and interactive procedures, see "SAS Tip: Put ODS statements inside procedures."
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Save $200 when you sign up by March 14!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.