BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Quentin
Super User

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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 18 replies
  • 2493 views
  • 11 likes
  • 6 in conversation