I am trying to print observations from a dataset into a file using the IML submit/endsubmit block. I submit the code below and observe that the appropriately-named file appears in the desired directory but it is empty: it has 0 bytes in it. I do not understand what I have done or not done. In this example, I want to display the file SASHELP.CLASS.
proc iml ;
out_path = "/home/rsbettinger/FuzzyFeatSel/Project/Iris" ;
dsname='test' ;
out_pdf = cats( out_path, '/', dsname, '_featsel_table.pdf' ) ;
print out_pdf ;
submit ;
ods listing file="/home/rsbettinger/FuzzyFeatSel/Project/Iris/test.pdf" style=sapphire ;
proc print data=sashelp.class noobs ; run ;
ods listing close ;
endsubmit ;
quit ;
Initially, I submitted the code to create a PDF file, using "ods pdf file="..." but not even the file was created in the named directory, so I tried "ods listing file="..." which at least created an empty file.
Is there some subtle error "under the hood" here or am I making a newbie error?
TIA,
Ross
> Initially, I submitted the code to create a PDF file, using "ods pdf file="..." but not even the file was created in the named directory,
You must use ODS PDF if you want to create a PDF file. I don't know why the SUBMIT statement doesn't allow the ODS statement inside. I think the SUBMIT statement inherits the ODS environment that was in effect when it was called, which is usually what you want to happen. So, put the ODS and ODS CLOSE statements outside the SUBMIT block:
%let HOME = %sysfunc(getoption(SASUSER));
%put &HOME;
proc iml ;
print "Before the SUBMIT stmt";
ods PDF file="&HOME\test.pdf" style=sapphire ;
submit ;
proc print data=sashelp.class(obs=5) ; run ;
endsubmit ;
ods PDF close;
print "After the SUBMIT stmt";
> Initially, I submitted the code to create a PDF file, using "ods pdf file="..." but not even the file was created in the named directory,
You must use ODS PDF if you want to create a PDF file. I don't know why the SUBMIT statement doesn't allow the ODS statement inside. I think the SUBMIT statement inherits the ODS environment that was in effect when it was called, which is usually what you want to happen. So, put the ODS and ODS CLOSE statements outside the SUBMIT block:
%let HOME = %sysfunc(getoption(SASUSER));
%put &HOME;
proc iml ;
print "Before the SUBMIT stmt";
ods PDF file="&HOME\test.pdf" style=sapphire ;
submit ;
proc print data=sashelp.class(obs=5) ; run ;
endsubmit ;
ods PDF close;
print "After the SUBMIT stmt";
Rick,
Your example worked properly, but I am still mystified as to why my code did not work. Here is additional code in the same program that produces a graph:
ods graphics / reset=all ;
imagename = cats( "FuzzyFeatSel_", dsname, "_graph" ) ;
submit dsname imagename out_path table_title ;
ods listing gpath="&OUT_PATH" IMAGE_DPI=150 style=statistical ;
ods graphics on / border=on height=8in imagename="&IMAGENAME" outputfmt=png ;
title &TABLE_TITLE ;
proc sgplot data=subset_data ;
series x="Number of Variables in Subset"n y="Fuzzy Entropy"n /
datalabel="Variable Name"n datalabelattrs=(size=6) datalabelpos=topright markers ;
xaxis label='Number of Variables in Subset' ;
yaxis label='Fuzzy Entropy' ;
run ;
*** ods graphics off ; /* turned off b/c it interferes with rendering (causes height= to fail) */
endsubmit ;
Why does the included code work but the simpler example does not work? Inquiring minds want to know.
Thanks much,
Ross
> Why does the included code work but the simpler example does not work? Inquiring minds want to know.
I will repeat myself: "I don't know why the SUBMIT statement doesn't allow the ODS statement inside."
A fundamental architectural design of SAS procedures is that only one procedure is ever running at one time. Normally, if you submit "PROC SGPLOT," the first thing that happens is that it terminates whatever procedure was previously running. When a procedure exits, it does many ODS-related things, such as clearing the select list, flushing pending tables, and closing the ODS connection that it was using. The fact that SAS was able to create a SUBMIT block is rather miraculous because PROC IML continues to run and even resumes its current state and its ODS environment after the ENDSUBMIT statement. I suspect that preserving the state of the ODS environment for PROC IML comes at a cost, but I do not know any details about how ODS works inside the SUBMIT block.
Rick,
Thank you for an informative answer.
Ross
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.