Your SAS programs, embedded in web apps and elsewhere

Include Changes Display

Accepted Solution Solved
Reply
Super Contributor
Posts: 483
Accepted Solution

Include Changes Display

I used an include to add:

%include "/sashome/programs/storedprocess/devl/Research_Dashboard_Util.sas";

I cut code from a file and added it to a second file to include the code back into the file that will uses the included code.  The code with or without the include should is identical.  However it looks like my ods html changes around the footnote section displaying the background as gray rather than white.


I even commented out all of the file I am including and the gray line still exists so long as I have:

%include "/sashome/programs/storedprocess/devl/Research_Dashboard_Util.sas";


I am using SAS 9.2 and displaying my stored process in a web URL portlet.


Accepted Solutions
Solution
‎07-07-2015 04:42 PM
Super User
Posts: 10,538

Re: Include Changes Display

Easiest if you have an Autoexec.sas add

options insert = (SASAUTOS= ("path to put your files");

And then in that folder place files with the macro code. One file per macro. Each file must be named the same as the macro, no other executable code in the file and best if the first line in the file starts with %macro.

You can have multiple entries for the paths for different autocall libraries for different projects if that makes sense to you.

View solution in original post


All Replies
Super User
Posts: 10,538

Re: Include Changes Display

Are then any STYLE statements involved in the code?

Does the FOOTNOTE code include any graphic elements? (ie something other than just text)

Does the included program have any %include statements? Or modify any variables that may be used for display options?

You might want to post the code for that included program since that seems to be the likely culprit.

Super Contributor
Posts: 483

Re: Include Changes Display

I changed the included file to a blank .SAS file for testing.


Yes there are small images.


This is at the top of the file:

%GLOBAL _ODSDEST _ODSSTYLE;

This is before the macro call:

%LET _ODSDEST=HTML;

%LET _ODSOPTIONS=gtitle gfootnote style=normal;


This is the section that acts up:


%MACRO DisplayToolbar();

%LET COMMAND = %nrstr("/SASPortal/Director?_directive=STPRun&_action=execute&_program=");

%LET SP = %SYSFUNC(URLENCODE(&_PROGRAM));

%IF &VIEW=DEFAULT %THEN

  %LET SELF_URL=&SERVER.&COMMAND.&SP;

%ELSE

  %LET SELF_URL=&ADMIN_LINK;

%LET SP_NAME=%SYSFUNC(SCAN(&_PROGRAM,-1,'/'));

%LET PORTLET_TITLE = %SYSFUNC(URLENCODE(&SP_NAME));

%LET MAX = %nrstr("&FORMAT=")MAXIMIZE;

%LET EXCEL = %nrstr("&FORMAT=")EXCEL;

%LET PDF = %nrstr("&FORMAT=")PDF;

%LET SELF_URL_MAX = &SELF_URL.&MAX;

%LET SELF_URL_EXCEL = &SELF_URL.&EXCEL;

%LET SELF_URL_PDF = &SELF_URL.&PDF;

%LET HELP_SP = %2FReports%2FResearch+Dashboard%2FResearch+Dashboard+Help;

%LET HELP_PARAM = %nrstr("&Portlet_Title=");

%LET HELP_URL = &SERVER.&COMMAND.&HELP_SP.&HELP_PARAM.&PORTLET_TITLE;

%LET link1=<a href="&SELF_URL_MAX" target=_blank><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1340286016503/home/maximize-icon.gif' alt='Maximize' title='Maximize' height='15' width='15' style='border:none;' /></a>;

%LET link2=<a href="&SELF_URL_EXCEL" target=_blank><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1340285950455/home/export-icon.gif' alt='Export to Excel' title='Export to Excel' height='15' width='15' style='border:none;' /></a>;

%LET link3=<a href="&SELF_URL_PDF" target=_blank><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1344203338849/home/pdf-icon.gif' alt='Export to PDF' title='Export to PDF' height='15' width='15' style='border:none;' /></a>;

%LET link4=<a href='javascript:window.print()'><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1340286055280/home/print-icon.gif' alt='Print' title='Print' height='15' width='15' style='border:none;' /></a>;

%LET link5=<a href="&HELP_URL" target=_blank><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1340285967063/home/help-icon.gif' alt='Help' title='Help' height='15' width='15' style='border:none;'/></a>;

FOOTNOTE1 J=L "&link1 &link2 &link3 &link4 &link5";

%MEND DisplayToolbar;

Super Contributor
Posts: 483

Re: Include Changes Display

This is a full stored process with the bug

%GLOBAL _ODSOPTIONS _ODSDEST _ODSSTYLE VIEW SERVER;

%LET SERVER = https://&_SRVNAME;

%LET _DEBUG=TIME,FIELDS;

RUN;

%include "/sashome/programs/storedprocess/devl/Research_Dashboard_Util.sas";

%MACRO DisplayToolbar();

%LET COMMAND = %nrstr("/SASPortal/Director?_directive=STPRun&_action=execute&_program=");

%LET SP = %SYSFUNC(URLENCODE(&_PROGRAM));

%LET SELF_URL=&SERVER.&COMMAND.&SP;

%LET SP_NAME=%SYSFUNC(SCAN(&_PROGRAM,-1,'/'));

%LET PORTLET_TITLE = %SYSFUNC(URLENCODE(&SP_NAME));

%LET MAX = %nrstr("&FORMAT=")MAXIMIZE;

%LET EXCEL = %nrstr("&FORMAT=")EXCEL;

%LET PDF = %nrstr("&FORMAT=")PDF;

%LET SELF_URL_MAX = &SELF_URL.&MAX;

%LET SELF_URL_EXCEL = &SELF_URL.&EXCEL;

%LET SELF_URL_PDF = &SELF_URL.&PDF;

%LET HELP_SP = %2FReports%2FResearch+Dashboard%2FResearch+Dashboard+Help;

%LET HELP_PARAM = %nrstr("&Portlet_Title=");

%LET HELP_URL = &SERVER.&COMMAND.&HELP_SP.&HELP_PARAM.&PORTLET_TITLE;

%LET link1=<a href="&SELF_URL_MAX" target=_blank><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1340286016503/home/maximize-icon.gif' alt='Maximize' title='Maximize' height='15' width='15' style='border:none;' /></a>;

%LET link2=<a href="&SELF_URL_EXCEL" target=_blank><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1340285950455/home/export-icon.gif' alt='Export to Excel' title='Export to Excel' height='15' width='15' style='border:none;' /></a>;

%LET link3=<a href="&SELF_URL_PDF" target=_blank><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1344203338849/home/pdf-icon.gif' alt='Export to PDF' title='Export to PDF' height='15' width='15' style='border:none;' /></a>;

%LET link4=<a href='javascript:window.print()'><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1340286055280/home/print-icon.gif' alt='Print' title='Print' height='15' width='15' style='border:none;' /></a>;

%LET link5=<a href="&HELP_URL" target=_blank><img src='https://sites.google.com/site/dashboardsamples/_/rsrc/1340285967063/home/help-icon.gif' alt='Help' title='Help' height='15' width='15' style='border:none;'/></a>;

FOOTNOTE1 J=L "&link1 &link2 &link3 &link4 &link5";

%MEND DisplayToolbar;

%MACRO PrintReport();

%STPBEGIN;

  title "Basic PROC REPORT Report";

  proc report data=sashelp.class;

  run;

%STPEND;

%MEND PrintReport;

%MACRO ProcessReport();

  %LET _ODSDEST=HTML;

  %LET _ODSOPTIONS=gtitle gfootnote style=normal;

  %DisplayToolbar();

  %PrintReport();

%MEND ProcessReport;

%ProcessReport();

The error only occurs when you view the stored process via a web URL Portlet.

Super Contributor
Posts: 483

Re: Include Changes Display

I think the Include is including other things as well.  Is there a way to only include the macros?

Super User
Posts: 10,538

Re: Include Changes Display

You could move the macros to an autocall library. Then they would be compiled when needed.

Super Contributor
Posts: 483

Re: Include Changes Display

Researching how to make an autocall library.

Solution
‎07-07-2015 04:42 PM
Super User
Posts: 10,538

Re: Include Changes Display

Easiest if you have an Autoexec.sas add

options insert = (SASAUTOS= ("path to put your files");

And then in that folder place files with the macro code. One file per macro. Each file must be named the same as the macro, no other executable code in the file and best if the first line in the file starts with %macro.

You can have multiple entries for the paths for different autocall libraries for different projects if that makes sense to you.

Super Contributor
Posts: 483

Re: Include Changes Display

How do I tell if I have an AUTOEXEC?

I tried the second option in: http://support.sas.com/kb/24/451.html

I created a folder in:

/sashome/programs/storedprocess/devl/Research_Dashboard_Util

I uploaded a file with one macro and named the file the same name as the macro with .SAS extension.


I tried calling the autocall library.

FILENAME fileref '/sashome/programs/storedprocess/devl/Research_Dashboard_Util/';

OPTIONS MAUTOSOURCE SASAUTOS=(SASAUTOS fileref);


It looks like my macro was not pulled in.

Regular Contributor
Posts: 217

Re: Include Changes Display

When working with Macros in a Stored Process, it is best(?) to assign them as global.  If "_ODSOPTIONS" is not defined as global, SAS could be assigning "_ODSOPTIONS" as a local variable.  In the EG documentation I read about Stored Processes, it said, for best results, to assign macro variables as global before the %stpbegin statement.

%MACRO ProcessReport();

  %LET _ODSDEST=HTML;

  %LET _ODSOPTIONS=gtitle gfootnote style=normal;

  %DisplayToolbar();

  %PrintReport();

%MEND ProcessReport;

%ProcessReport();

Super Contributor
Posts: 483

Re: Include Changes Display

_ODSOPTIONS is global.  See line:


%GLOBAL _ODSOPTIONS _ODSDEST _ODSSTYLE VIEW SERVER;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 966 views
  • 3 likes
  • 3 in conversation