Thanks @yabwon , looking at SASHELP.VEXTFL is really nice.
Everything seems to be working really well in DOSUBL. The side session can see filerefs from the main session, and if you create a side session fileref it will see that one, etc.
It just seems like a problem with ODS statement not being able to see the side-session filerefs. I guess some "part" of the ODS statement is executing in the main session.
But as you show, if you can avoid using a fileref on the ODS statement, all is well.
The pathname() function also recognises reference correctly, what may give some workaround for the issue:
data _null_ ;
rc=dosubl(
'
filename foo "/path/to/some/directory/" ;
ods html
path="%sysfunc(pathname(foo))"
file="foo.htm"
;
proc print data=sashelp.class ;run ;
ods html close ;
filename foo clear ;'
) ;
run ;
Bart
One more example (with PDF) now:
1 data _null_ ;
2 rc=dosubl(
3 '
4 filename foo "%sysfunc(pathname(work))/foo123.pdf" ;
5
6 ods pdf file="%sysfunc(pathname(foo))"
7 ;
8 proc print data=sashelp.class ;run ;
9 ods pdf close ;
10 filename foo clear ;'
11 ) ;
12 run ;
NOTE: Writing ODS PDF output to DISK destination "R:\_TD23484_YABWONL5P_\foo123.pdf", printer "PDF".
NOTE: This SAS session is using a registry in WORK. All changes will be lost at the end of this
session.
NOTE: Writing HTML Body file: sashtml.htm
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
NOTE: ODS PDF printed 1 page to R:\_TD23484_YABWONL5P_\foo123.pdf.
NOTE: Fileref FOO has been deassigned.
NOTE: DATA statement used (Total process time):
real time 0.11 seconds
cpu time 0.11 seconds
13
14 data _null_ ;
15 rc=dosubl(
16 '
17 filename bar "%sysfunc(pathname(work))/bar123.pdf" ;
18
19 ods pdf file=bar
20 ;
21 proc print data=sashelp.class ;run ;
22 ods pdf close ;
23 filename bar clear ;'
24 ) ;
25 run ;
ERROR: Unable to resolve fileref BAR. ODS PDF initialization fails.
ERROR: Logical name is not available.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Fileref BAR has been deassigned.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.07 seconds
cpu time 0.03 seconds
Bart
The call execute() is "in the same session" as all ODS references so there is no confusion "where to look for reference".
The only thing I would add to the workaround code would be %NRSTR() wrapper, to ensure that 4GL and macro code will run in proper timing:
data _null_;
set test;
cmd=cats('%NRSTR(%test(',value,'));');
call execute(cmd);
run;
Bart
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.