BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ertr
Quartz | Level 8

Hello everyone,

 

I posted the following code for another question

 

(https://communities.sas.com/t5/SAS-Procedures/Proc-Logistic-How-to-Pull-Specific-Statistical-Values/...)

 

,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

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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."

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

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."

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 838 views
  • 2 likes
  • 2 in conversation