I have a trouble with Ods Output now, the macro for LR works.
I used the similar ods output to collect pvalues in the PHREG statement and it was totally fine, but now I am given the error message that the variable 'Parameter' has never been referenced. Also I am getting this WARNING: Duplicate data set name on ODS OUTPUT statement. Entry will be ignored.
here is my program:
%DO I=1 %TO x;
ods output ParameterEstimates=Results;
DATA a; SET b; df=d*f; RUN;
proc logistic descending data=a;
MODEL y=d f df e.. ;
ods OUTPUT close;
DATA Estimate; SET Results; WHERE Parameter="df"; KEEP Parameter
ProbChiSq ; RUN;
DATA PVALUE; SET PVALUE Estimate; RUN;
Every procedure can potentially write different column names to the ODS OUTPUT dataset. You need to check the column names before you use the output dataset in subsequent steps.
Possibly you need to change your WHERE condition to test for the value of VARIABLE. Perhaps something like this (which works with the above program):
KEEP Variable Estimate ProbChiSq ;
proc print data=estimate;
title 'WHERE Variable = Height';
One of the best practices when using SAS macros is to ensure that you have a working program BEFORE you "macro-ize" the program. Although ODS TRACE ON/TRACE OFF will show you the correct output object names for the ODS OUTPUT statement, you will need to verify the columns names in the output dataset using either PROC CONTENTS or PROC PRINT before you use the dataset in subsequent steps. The issue was not with SAS Macro, but was with not understanding what column names were created in the output dataset.
thank you for an attempt to resolve this, I did check the simple program before.
It does have the 'Parameter' variables listed in the output with their B-coefficients estimated, as well as ChiSq probabilities, OR, CI etc..
so i am not sure why it does not take 1) Parameter as a variable;
2) why it says that the 'Ods Output' has a duplicate data set name
Without seeing what's in your WORK.RESULTS, I have no idea why your WHERE statement does not work. If you posted your SAS LOG and the PROC PRINT of WORK.RESULTS, it might be possible to figure out more.
and, use the [pre] and [/pre] tags around your code and output in order to maintain indenting and spacing.)
Usually ODS OUTPUT gives you messages like your #2 question because you have a duplicate name in a situation where the name is expected to be unique. I could not duplicate that message, even when I put my PROC LOGISTIC inside a macro %DO loop.