Hi,
I'm trying to change the device in the SAS Information Delivery portal from activex to png.
I use the following code:
ods html file=_webout (no_bottom_matter);
ods html close;
ods html file =_webout (no_top_matter no_bottom_matter) ;
%let _gopt_device = PNG;
goptions device=&_gopt_device;
proc gchart data = sashelp.class;
vbar name / sumvar = age;
run;
quit;
ods html close;
ods html file=_webout (no_top_matter);
ods html close;
I created a stored process WITHOUT the default Stored Proces macro's and the .png output does not work. I see the following:
Does anyone can give me some help with this?
Thanks!
- Berry
Hi:
If you look inside your HTML file using Notepad, you will see an IMG tag that points to a physical location of a PNG file. When you use SAS on a server, the PNG file (or GSEG entry) is created up on the server. The way that the HTTP protocol works is that your HTML results come down to the browser from the server. Then the browser encounters the IMG tag. The browser sends a request back to the server for the image file to come down the pipeline. Then the server (if it still has the image) sends the PNG (or GIF or JPG) file back to the browser. This is the HTTP Request/Response protocol. The browser makes a request, the server sends a response. Only one type of output can come down the HTTP pipeline at a time -- so all the HTML comes down, then each separate IMG tag triggers a new request from the browser to the server.
Sometimes, when you use stored processes, your image file is gone after the SAS program has completed processing. So when the browser tries to go back for the image, the server has already closed down all the work areas that were allocated for your stored process.
There are a couple of different ways to work with this fact: 1) persist a session, so that when the browser goes back for the image, your server session and work files are still active or 2) write the image to a fixed location on the server (requires that you get write access to a physical directory location on the server) and then use ODS PATH= and/or GPATH= to make ODS build the right link for the IMG tag or 3) have your stored process return package results -- which means that the image and the HTML would come down the pipeline together in an SPK archive file (SAS Package file). The method that you use will be determined by the client applications that you are using to run the stored process.
I'd recommend that you work with Tech Support on this. I am not sure why you have so many ODS HTML CLOSE and ODS HTML FILE= statements in your code. The issue is not really an ACTIVEX versus PNG issue or a DEVICE= issue (although you should have the ACTIVEX controls installed, if you want the interactivity) -- it is an issue of whether the created image can be found when the browser goes back to get whatever image is listed on the IMG tag.
cynthia
Dear Cynthia,
I encountered the same problem. I have about the same code without the first 2 lines and the last 2 lines in the example above. I use streaming and activex is ok - the graph is shown. When I switch to png the graph is not shown (x instead) and I get the error:
ERROR: insufficient authorization to access /var/opt/data/sas/sas92/sas_92/configDWH/Lev1/myproject/gchart.png
My STP is streaming. When I switch to Package I get nearly the same error with png:
ERROR: insufficient authorization to access /var/opt/data/sas/sas92/sas_92/configDWH/lev1/myproject/_webout.dat
I can't even use put with the data _null_ step to file _webout anymore with package (not only the graph isn't shown).
So even the package method tries to write the image to the server instead of sending the whole package (img and html site) to the client. Is there anything elese I have to change when I user package with SAS/GRAPH in an STP?
Best wishes
Eva
I don't typically use stored processes, but the last time I converted one of my standalone samples to run as a stored process, I made some detailed notes on exactly how I set it up to use dev=png and to use gtitles, etc. I can't guarantee these tips will work for you, but they should help. I believe I was using a 9.2 server when I took these notes. If it's still not working for you, definitely get in touch with SAS Tech Support and they should be able to help. (When you figure out the answer, please share it back in a reply post!)
Modify the standalone SAS Sample
--------------------
First, copy the sas job (ie, my sample) to the directory where you're
going to keep your stored processes - in my case that was ...
C:\MySASData\StoredProcesses\esdmap_stp.sas
My sas samples are hard-coded to run standalone, and use ods html
to write out the gif (or png) and html file to the current directory -
you'll need to remove that hard-coding, and add a few lines with the
magic-incantations to let it run as a stored process...
First, I deleted the following line at the top of my sas job...
filename odsout '.';
Then I deleted/replaced the following ods lines...
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" (title="Some text") style=minimal;
With the following stored-process-specific lines. These special macro
variables are *very* important, and they tell stpbegin to run the job
using dev=gif (or png) and to keep the titles inside the graph (otherwise
the stored process will default to device=activex, and the titles will
be outside the graph - this has confused many people, because
stpbegin ignores your normal device=gif (or png) and "ods gtitles" statements).
So, just take my word for it -- this is *very* necessary!
(Note - as of v9.2, it's probably preferable to use dev=png than gif
because png supports 16-million colors, and gif only supports 256.
And also, if you're using a style other than 'minimal', specify that
style here - I use style=minimal a lot, but you might prefer
something different)
%let _GOPT_DEVICE=png;
%let _ODSOPTIONS=gtitle gfootnote style=minimal;
%stpbegin;
And at the end of the sas job I deleted/replace the following ods lines ...
ods html close ;
ods listing ;
With the following line...
%stpend;
=====
Register The SAS Sample as a Stored Process
-------------------------------------------
Run the SAS Management Console (SMC)...
Start->All Programe->SAS->SAS Management Console
First time you use the SMC you might have to define some things
in the metadata profile wizard, such as...
Name of metadata profile (I usually take the default)
Machine:
Userid:
Password:
(next)
Foundation Repository
(next)
Finish
Navigate to the area where you (or someone) has set up for stored processes, such as ...
SMC -> BI Manager -> BIP Tree -> ReportStudio -> Shared -> Reports -> Stored Processes
In my case, it was...
SMC -> BI Manager -> BIP Tree -> ReportStudio -> Shared -> Stored Processes
Right-Mouse-Button -> New Stored Process
You'll then tell it the directory/filename/etc of your sas job
(In my case the directory was C:\MySASData\StoredProcesses\
and my sas job was "esdmap_stp.sas")
SAS Server: SASMain - Logical Stored Process Server
(Vince Delgobbo says since my jobs require streaming, they can't be run on
the Workspace Server, and you must choose the Stored Process Server)
SAS Source Code Repository: the physical directory where your sas jobs are
(In my case that was C:\MySASData\StoredProcesses\ )
Source File: your sas job's filename
(In my case that was esdmap_stp.sas )
Input: (leave blank)
Output: streaming
Most of my sas jobs are standalone samples that require no user-input
therefore you don't have to register any parameters.
At this point, the Stored Process should be ready to go.
Dear Robert,
my STP is created as you said. It runs on a Logical Stored Process Server, it is Streaming, and the directory for the source code is correct. And it lies in the BIB Tree like you wrote. I have some parameters but that shouldn't be the problem.
I did not enclose the STP macros in the dialog where you create the STP (enclose in SAS Code -> STP Macros) because I use
data _null_;
file _webout;
put "<h1> my report</h1>";
[etc.]
run;
I need these data _null_ steps to create the HTMl design around the graphs (I have a complete Webapplication with HTML form, Javascript, CSS, etc. where the Graphs are part of it). The put with the <h1> is only a simply example of HTML code.
If I'd enclosed the STP macros then I'd get the error: file _webout is in use.
So what I did instead is write the %stpbegin; right in front of the graph code. And the %stpend; right after the graph code (because after that I need some more data _null_; with put and HTML Code.
[HTML,CSS,Javascript code for web application]
ods html file=_webout(no_top_matter no_bottom_matter) encoding="utf-8";
%stpbegin;
goptions reset=all device=png cback=CXFAFAFA xpixels=800;
[graph code]
%stpend;
ods _all_ close;
[HTML Code for web application]
Now it works. I have png graphs. But to be honest I have several other problems now. SAS now overwrites my CSS. It sets a background color, changes fonts and colors :smileyshocked: Because the %stpbegin; writes CSS into my HTML output. What I found important in my web application is that I prevent SAS from writing any style information. Because I'd like to do that myself with CSS. Can I prevent %stpbegin from doing this?
Best wishes
Eva
See if this works for you:
ods _all_ close;
ods html file =_webout (no_top_matter no_bottom_matter)
path=&_TMPCAT (url=&_REPLAY);
goptions device=png;
proc gchart data = sashelp.class;
vbar name / sumvar = age;
run; quit;
ods html close;
Vince DelGobbo
SAS R&D
Dear Vince,
yes that did the job. However the site now loads about 4 times slower than before.
Best wishes
Eva
Hi Eva,
When you say:
However the site now loads about 4 times slower than before.
Do you mean changing from device=activex to device=png slowed things down that much?
I haven't done much with activex, but I guess wouldn't be too shocked to see png slow things down, since the .png file is (I assume) bigger than the amount of data that needs to be returned for the activex plot. And, as pointed out, ach png file requires it's own request from the browser to the server. Kind of like the first days of the internet, when if you wanted to have blazingly fast web browsing over your 56k modem, you just turned off images...
Sound like a reasonable explanation? (that's really a question, I'm new to SAS/web stuff)
--Q.
Dear Quentin,
no I meant it slowed down when I used path=&_tmpcat (url=&_replay) instead of %stpbegin and %stpend.
Best wishes
Eva
Thank Eva,
I would be surprised if adding path=&_tmpcat (url=&_replay) instead of %stpbegin made things slower. When you call %stpbegin, and are in the appropriate setting (e.g. streaming results to _webout, with a graphics device that requires 'lightweight sessions', etc), it generates the path=&_tmpcat (url=&_replay) options when it generates the ODS statement. [There isn't any magic in %stpbegin (well there is magic, but not MAGIC), it's a regular macro, you can open stpbegin.sas and see what it's doing.]
--Q.
Dear Quentin,
I tried it again and now the performance is ok. I guess it was a temporary performance problem on our server and not a problem of the changed code.
Thanx a lot for the hint between loading time for png and other image types! I'll consider this.
Best wishes
Eva
Hi - When I tried to use _webout with path=&_TMPCAT (url=&_REPLAY), the stored process does not seem to know the special macro &_TMPCAT and &_RELAY
My stored process has the execution server set to 'Logical Workspace Server', but when I tried to set it to 'Logical Stored Process Server' to use 'streaming' output, it would not let me. All it does is to keep running like a loop with no end.
So here are my questions:
1) Do I have to set the output to ‘streaming’ in order for a stored process to recognize &_TMPCAT and &_RELAY?
2) Do I have to re-install SAS again to correct the 'Logical Stored Process Server' issue?
Any help would be greatly appreciated!
Hi,
1. Yes, &_TMPCAT and &_REPLAY are only used when the results are streaming. If you send package results, they are not applicable. (As I understand it)
2. I don't understand question #2. Are you using Enterprise Guide or SAS Management Console to create the stored process? How are you trying to set the execution sever? Are they suggesting that you reinstall SAS on the server (seems odd?) or reinstall EG (also seems odd?). What version(s) are you running?
--Q.
Hi Quentin,
Thanks for the prompt response. Let me clarify on #2 in the order of your questions:
1) Yes, I used the wizard on EG to create the stored process
2) At step 3 of 5 onthe Execution Server step where a drop-down list allows me to select 'Logical Stored Process Server' or 'Logical Workspace Server'
3) No, not on the server, they suggested SAS to be reinstalled on my PC
4) I am running on EG 4.3
Sorry for not being clear at first. Thanks again!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: