I am attempting to update my halfnorm macro for V9+, current version at
Visualizing Categorical Data: halfnorm - Half normal plot for generalized linear models
I'm having trouble with a section of the macro designed to run proc genmod repeatedly to get a simulated envelope
based on randomly generated values from a given distribution. I would prefer to have no printed output generated,
but commented out the ODS LISTING statements for now. The essence is the following loop:
%put HALFNORM: Generating &nres simulated residual sets...;
%if %sysevalf(&sysver >= 7) %then %do;
* ods listing exclude all;
%end;
%do i=1 %to &nres;
options nonotes;
%*put Generating residual set &i;
ods output ObStats=work._hres&i(keep=&res rename=(&res=res&i));
proc genmod data=_obstat_;
%if %length(&class)>0 %then %do; class &class; %end;
%if %length(&freq)>0 %then %do; freq &freq; %end;
%if %length(&trials)=0 %then %do;
model _y&i = &model /
%end;
%else %do;
model _y&i/&trials = &model /
%end;
%if %length(&dist)>0 %then %do; dist=&dist %end;
%if %length(&link)>0 %then %do; link=&link %end;
%if %length(&offset)>0 %then %do; offset=&offset %end;
%if %length(&mopt)>0 %then %do; %str(&mopt) %end;
obstats residuals;
* make 'obstats' out=_hres&i(keep=&res rename=(&res=res&i));
run;
%end; /* End %do i */
I'm getting warnings, then errors regarding the ObStats datasets when I try to use them
HALFNORM: Generating 19 simulated residual sets...
MPRINT(HALFNORM): * ods listing exclude all;
MPRINT(HALFNORM): options nonotes;
MPRINT(HALFNORM): ods output ObStats=work._hres1(keep=stresdev
rename=(stresdev=res1));
MPRINT(HALFNORM): proc genmod data=_obstat_;
MPRINT(HALFNORM): class dept gender admit;
MPRINT(HALFNORM): model _y1 = dept|gender|admit@2 / dist=POISSON obstats
residuals;
MPRINT(HALFNORM): * make 'obstats' out=_hres&i(keep=&res rename=(&res=res&i));
MPRINT(HALFNORM): run;
WARNING: Output 'ObStats' was not created. Make sure that the output object
name, label, or path is spelled correctly. Also, verify that the
appropriate procedure options are used to produce the requested output
object. For example, verify that the NOPRINT option is not used.
...
I attach the current version I'm testing, together with a log file from a test run. Can anyone see what is wrong and how to correct it?
Test code:
title 'Berkeley Admissions data';
%include catdata(berkeley);
data berkeley;
set berkeley;
cell = trim(put(dept,dept.)) ||
gender ||
trim(put(admit,yn.));
%include macros(halfnorm12);
options mprint;
%halfnorm(data=berkeley, class="dept" gender admit,
resp=freq, model=dept|gender|admit@2, dist=poisson, id=cell);
Is there a reason that the OUTPUT= option for creating dataset output isnt' acceptable?
The online help suggests these reasons for using this option:
The OUTPUT statement creates a SAS data set more efficiently than ODS. This can be an advantage for large data sets.
You can specify the individual statistics to be included in the SAS data set.
Thanks for the suggestion, but the
OUTPUT statement is not currently an option, at least not without a major re-write.
This may turn out to provide a good solution, but I'd rather see if I can tweak the ODS first.
The OUTPUT statement did not exist when the macro was originally written. It provides similar output statistics
to what is available via ODS, but seems to have been constructed by an independent contractor, because the names
of the output variables differ in a bewildering way.
e.g.,
OBSTATS OUTPUT
streschi stdreschi
stresdev stdresdev
...
Michael,
I don't know if the attached fixes your problem, but it runs without error on 9.3.
I may have made some additional changes that I don't now remember, but the only significant ones I can recall are having changed your comments to /* */ type rather than the * type, and commenting out one additional statement, namely:
ods listing exclude none; |
HTH,
Art
Or if you annony these information , you can redirect them into a txt file .
Like something :
proc printto log='c:\log.txt' ;run;
..............
proc printto;run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.