BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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:

%MACRO logistic;
%local I;

%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.. ;
RUN;

ods OUTPUT close;

DATA Estimate; SET Results; WHERE Parameter="df"; KEEP Parameter
ProbChiSq ; RUN;

DATA PVALUE; SET PVALUE Estimate; RUN;
%END;
%MEND logistic;
%logistic;
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
Let's remove SAS macro from the picture. When I run this code:
[pre]

ods output ParameterEstimates=Results;

proc logistic descending data=sashelp.class;
MODEL age=height weight;
RUN;

ods listing;

proc contents data=work.results;
run;

proc print data=work.results;
run;
[/pre]

I do NOT see a column called "Parameter" in WORK.RESULTS. This is what I see in WORK.RESULTS:
[pre]
Class Prob
Obs Variable Val0 DF Estimate StdErr WaldChiSq ChiSq

1 Intercept 16 1 -33.6021 11.1725 9.0455 0.0026
2 Intercept 15 1 -30.0342 10.7184 7.8519 0.0051
3 Intercept 14 1 -28.1425 10.4843 7.2052 0.0073
4 Intercept 13 1 -26.7933 10.2666 6.8108 0.0091
5 Intercept 12 1 -23.8218 9.8517 5.8470 0.0156
6 Height 1 0.3577 0.2039 3.0777 0.0794
7 Weight 1 0.0576 0.0447 1.6597 0.1976

[/pre]

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):
[pre]
DATA Estimate;
SET Results;
WHERE Variable="Height";
KEEP Variable Estimate ProbChiSq ;
RUN;

proc print data=estimate;
title 'WHERE Variable = Height';
run;
[/pre]

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.

cynthia
deleted_user
Not applicable
Hello,

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
Cynthia_sas
SAS Super FREQ
Hi:
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.

(If you are going to post the SAS log or SAS output, then do read this forum posting
http://support.sas.com/forums/thread.jspa?messageID=27609毙

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.

cynthia

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
  • 3 replies
  • 2911 views
  • 0 likes
  • 2 in conversation