BookmarkSubscribeRSS Feed
Obsidian | Level 7

Hi all,


I am using PROC LOGISTIC on multiple datasets , for this I am using macro. Is there a way so I can export the results to excel sheet for each dataset.

I tried using ODS TAGSETS.Excelxp, but not working:


%macro build(in_ds);

ods graphics on;

proc logistic data=&in_ds. ALPHA=0.05  outmodel=DS_MDL;

class var1 var2 var3;

model y=x / options;

score data=&in_ds. out=ds_scr;


ods graphics off;



OPTIONS ( Orientation = 'landscape'
FitToPage = 'yes'
Pages_FitWidth = '1'
Pages_FitHeight = '100' );








I want to create separate reports for 3 datasets, the report name can be passed as a parameter to macro.

Please suggest.


Diamond | Level 26 RW9
Diamond | Level 26

Use the dark and forgotten art of by group processing. 

ods tagsets.excelxp file='d:/worksas9regression.xml' style=minimal options(orientation='landscape' fittopage='yes' pages_fitwidth='1' pages_fitheight='100');

data have;
  length ds_name $20;
  set dataset1 dataset2 dataset3 indsname=tmp;

ods graphics on;

proc logistic data=have alpha=0.05 outtmodel=ds_mdl;
  by ds_name;
  class var1 var2 var3;
  model y=x / options;
  score data=have;

ods graphics off;

ods tagsets.excelxp close;

Do note I have corrected the various typos, the random casing, lack of indents etc.  I also called the filename xml which is what you are actually creating here by use of a tagset.  Also note in the tagset options you may need to set sheet_inteval='bygroup'.  As I have nothing to test this on it isn't tested.

Obsidian | Level 7


The datasets here are all having different set of columns.

Is there any way to avoid data-set statement part..

Diamond | Level 26 RW9
Diamond | Level 26

Pleas post some test data, and code which accurately reflect what you have, we can only go on what you post here.  Your error is to do with gpath:


If the datasets are different and the variables are different, how are you aiming to get the different variables into the macro code?  If the same variables are being used in the model each time, just keep them in the dataset.  If they are different variables then show how this will go into the macro.


Please explain what "not working" means. And: post code using either {i} or running-man icon.


There seems to be an error in the specification of the file that ods should generate.

Obsidian | Level 7


%macro build_model(in_dset);
     ods graphics on;
     proc logistic data=&in_dset. ALPHA=0.05  /*&model_plots.*/ outmodel=ds_MDL;
     class &list_class_vars.;
     model DEFAULT_FLAG(EVENT='1')=&list_loan_vars. &selected_macroeconomic_vars.  / &model_opts.;
     score data=&in_dset. out=ds_SCR;
     ods graphics off;
%mend build_model;

%let plot_path = /home/../../../reports;
ods tagsets.ExcelXP file="&plot_path./report.xml" style=minimal options(orientation='landscape' FittoPage = 'yes' Pages_FitWidth ='1' Pages_FitHeight = '100');
ods tagsets.ExcelXP close;

error message:
NOTE: Convergence criterion (GCONV=1E-8) satisfied in Step 17.
NOTE: Convergence criterion (GCONV=1E-8) satisfied in Step 18.
NOTE: Convergence criterion (GCONV=1E-8) satisfied in Step 19.
NOTE: Convergence criterion (GCONV=1E-8) satisfied in Step 20.
WARNING: GPATH or PATH is not a writable directory. It will be ignored.
ERROR: Cannot write image to . Please ensure that proper disk permissions are set.
ERROR: Cannot write image to . Please ensure that proper disk permissions are set.
NOTE: The SAS System stopped processing this step because of errors.

Please find my code and error messages.


Super User

I don't believe the XML files that tagsets.excelxp generates can contain graphics. Either make sure that there are no graphics generated or use a different destination such as ODS RTF or ODS PDF.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1 like
  • 4 in conversation