BookmarkSubscribeRSS Feed
ScottBass
Rhodochrosite | Level 12

Hi,

Sorry if this is a simple question...

In the SPWA, I can select the "Show SAS log" if that prompt is added to the stored process prompts, or I can add &_debug=131 to the end of the stored process URL.

If the output is HTML, that's great, I get the SAS log underneath the HTML output.

But how do I get the same functionality if the output is PDF?

I only get this in my stored process server log - no SAS log information.  Do I need to turn on more verbose logging to see the SAS log?

2012-08-23T17:33:37,059 INFO  [00004258] :sassrv@MYMACHINE - New out call client connection (47) for user sbass@DOMAIN.  Encryption level is Credentials using encryption algorithm SASPROPRIETARY.  Peer IP address and port are [10.64.22.60]:8562.

2012-08-23T17:33:37,060 INFO  [00004258] :sbass@DOMAIN - New client connection (46) accepted from server port 8612 for SAS token user sbass@DOMAIN.  Encryption level is Credentials using encryption algorithm SASPROPRIETARY.  Peer IP address and port are [::ffff:10.64.22.61]:65064 for APPNAME=Stored Process Web App 9.3.

2012-08-23T17:33:37,062 INFO  [00004266] 46:sbass@DOMAIN - STP: 22: Creating New Context, sessionID=

2012-08-23T17:33:37,159 INFO  [00004266] 46:sbass@DOMAIN - STP: Sending cost=101 to Load Balancer. Context Cost=100 STP Session Cost=1

2012-08-23T17:33:37,212 INFO  [00000003] :sassrv@MYMACHINE - [00000022] STPXMVA *** Ready for requests ***

2012-08-23T17:33:37,218 INFO  [00000003] :sassrv@MYMACHINE - [00000022] STPXMVA Setting input arguments.

2012-08-23T17:33:37,219 INFO  [00004274] 46:sbass@DOMAIN - STP: 22: Executing E:\SAS\Config\Lev2\SASApp\SASEnvironment\Stored Processes zz_test.sas

2012-08-23T17:33:37,220 INFO  [00000524] :sassrv@MYMACHINE - [00000022] STPXMVA Submitting path "%include 'E:\SAS\Config\Lev2\SASApp\SASEnvironment\Stored Processes\zz_test.sas';" for execution.

2012-08-23T17:33:37,565 INFO  [00000003] :sassrv@MYMACHINE - [00000022] STPXMVA Execution complete.

2012-08-23T17:33:37,565 INFO  [00004274] 46:sbass@DOMAIN - STP: 22: Execution Complete.  Status=0

2012-08-23T17:33:37,566 INFO  [00004274] 46:sbass@DOMAIN - STP: 22: Fileref Deassign Success for _WEBOUT

2012-08-23T17:33:37,566 INFO  [00004274] 46:sbass@DOMAIN - STP: 22: Not Saving session 399450B6-1BB3-4858-8704-AF1BC3A072BC

2012-08-23T17:33:37,591 INFO  [00004342] 46:sbass@DOMAIN - STP: 22: Context Close

2012-08-23T17:33:37,591 INFO  [00004342] 46:sbass@DOMAIN - [00000022] STPXMVA_TK *** Begin Termination ***

2012-08-23T17:33:37,595 INFO  [00004342] 46:sbass@DOMAIN - [00000022] STPXMVA_TK *** Termination complete ***

2012-08-23T17:33:37,598 INFO  [00004342] 46:sbass@DOMAIN - STP: 22: Context Released from Server Tracker

2012-08-23T17:33:37,600 INFO  [00004342] 46:sbass@DOMAIN - STP: Sending cost=0 to Load Balancer. Context Cost=0 STP Session Cost=0

2012-08-23T17:33:37,602 INFO  [00004349] 46:sassrv@MYMACHINE - Client connection 46 for user sbass@DOMAIN closed.

2012-08-23T17:33:37,602 INFO  [00004349] 46:sassrv@MYMACHINE - Client connection 47 for user sbass@DOMAIN closed.

The reason I ask:  the below code (ODS layout) works fine in SAS DMS when sending to a PDF file.  But, when the (almost) identical code (edited to add the %stpbegin/%stpend macros) is called as a stored process, the output is incorrect:  the graph overwrites the proc print output.  I'm hoping the SAS log would show why.

options nodate nonumber orientation=landscape;

filename temp "C:\temp\temp.pdf";

ods _all_ close;

ods pdf file=temp bookmarkgen=no startpage=now;

ods layout start;

ods region x=0cm y=1cm height=5cm width=10cm;

title;

proc print data=sashelp.class;

  where age=14;

run;

ods region x=1cm y=6cm height=6cm width=10cm;

legend1 frame position = (bottom center);

axis1 style=1 width=1;

axis2 style=1 width=1 minor=(number=1);

title;

proc gchart data=sashelp.class;

  hbar age/

  sumvar=height

  subgroup=sex

  clipref

  frame nostats

  type=sum

  legend=legend1

  coutline=black

  maxis=axis1

  raxis=axis2;

run;

quit;

ods layout end;

ods pdf close;

ods results;


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
12 REPLIES 12
shivas
Pyrite | Level 9

Hi,

I ran the same code in SWP and it worked fine...

I just changed one value to 

ie.

ods region x=10cm y=6cm height=6cm width=10cm;


dest.png

Thanks,

Shiva

ScottBass
Rhodochrosite | Level 12

Thanks Shiva.  The graph should be below the table.

Would you be able to run the original code in SAS DMS, then run the same code as a stored process with PDF output (set via _ODSDEST)?  You'd need to add %stpbegin/%stpend and remove a few of the ODS statements (and let %stpbegin and the SPWA take over).  I'm not at work anymore otherwise I'd post a pic of the desired output.

I'd be curious if someone else could replicate my issue, where the code works in DMS and doesn't in SPWA.

BTW, we're on SAS 9.3.

Thanks,

Scott


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
lacrefa
Calcite | Level 5

Dear

view the SAS log from the stored process web application ? Thsi web application is similar to SAS /INtrnet , you can add the parameter in your URL or in your STP (hidden) define : _debug=139  (_debug=0 --> no log).

Regards

Quentin
Super User

Hi Scott,

Often I find it's easiest to just use PROC PRINTTO to write the log somewhere, and then read it in your favorite text editor.

The downside of this is that this completely redirects the log, so if you specify "show log" or &_debug=131 or whatever, you will only see the log up until proc printto was called.  (Would be nice if you could avoid this by using OPTIONS ALTLOG in a SAS session rather than PRINTTO, but only works at invocation)

I think the benefits to having the full log in a flat file are worth it.  For example, you can do automated log scanning.  Can also keep an archive of log files,  helpful when you have multiple users running stored processes you developed, who might call you tomorrow to say that they got a weird result from a report they ran last week...

--Q.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
ScottBass
Rhodochrosite | Level 12

lacrefa wrote:

Dear

view the SAS log from the stored process web application ? Thsi web application is similar to SAS /INtrnet , you can add the parameter in your URL or in your STP (hidden) define : _debug=139  (_debug=0 --> no log).

Regards

This doesn't work if the output type is PDF - as I stated in my original post.


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
Cynthia_sas
SAS Super FREQ

Hi:

  ODS LAYOUT is still "pre-production" in SAS 9.3. To figure out whether the issue is with your stored process code or with ODS PDF and whether it can implement ODS LAYOUT from inside a stored process delivered via the SPWA, your best bet for help is to open a track with Tech Support. I don't entirely understand why you're using STARTPAGE=NOW instead of STARTPAGE=NO and why you even need ODS LAYOUT if you want the graph underneath the table. But Tech Support really is your best resource for a question like this.

cynthia

ScottBass
Rhodochrosite | Level 12

OK, ignore the two-questions-in-one-post...

What's the best way to view the SAS log for a stored process invoked via the SPWA when the output is a PDF file?  Is Quentin's suggestion of PROC PRINTTO the best approach?  (Thanks Quentin...)

Regards,

Scott


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
shivas
Pyrite | Level 9

Hi,

I ran the code using SPWA and this the output I got.

dest.png

and stored process code which I have used...

*ProcessBody;

filename temp "F:\JMB\temp.pdf" ;

ods _all_ close;

ods pdf file=temp bookmarkgen=no startpage=now ;

%stpbegin;

ods layout start;

ods region x=0cm y=1cm height=5cm width=10cm;

title;

proc print data=sashelp.class;

  where age=14;

run;

ods region x=1cm y=6cm height=6cm width=10cm;

legend1 frame position = (bottom center);

axis1 style=1 width=1;

axis2 style=1 width=1 minor=(number=1);

title;

proc gchart data=sashelp.class;

  hbar age/

  sumvar=height

  subgroup=sex

  clipref

  frame nostats

  type=sum

  legend=legend1

  coutline=black

  maxis=axis1

  raxis=axis2;

run;

quit;

ods layout end;

ods pdf close;

ods results;

%stpend;

Quentin
Super User

Hi,

Follow-up note about my PROC PRINTTO suggestion.

As I understand it, when SPWA detects an error in the log, it pushes html code with the "This request completed with errors... " message  to _webout (I think).

So even with PROC PRINTTO redirecting most of the log file, if you use ods rtf or tagsets.excelxp, and there are errors in your program, looks like that html code gets appended to your output file.

With tagsets.ExcelXP, I ended up with an xml file that should end at </Workbook>, but ends up with the html after it:

</Row>

</Table>

</Worksheet>

</Workbook>

<h1>Stored Process Error</h1><h3>This request completed with errors.</h3>

<script type="text/javascript">/*<![CDATA[*/

function SAS_toggleLog() {

  var button, content, SASLogDisplay;

  button        = document.getElementById("SASLogbutton");

  content       = document.getElementById("SASLog");

  SASLogDisplay = content.style.display;

  if (SASLogDisplay == "none") {

    content.style.display = "inline";

    button.value="Hide SAS Log";

  }

  else {

    content.style.display = "none";

    button.value="Show SAS Log";

  }

}

/*]]>*/</script>

<form>

  <input id="SASLogbutton" class="button" type="button" onclick="SAS_toggleLog();" value="Show SAS Log" />

You can see the same junk at the end with ods rtf when SAS code has errors.

Word seems happy to ignore the extra html when opening the rtf.  Excel 2003 won't open the xml file.

I don't know how to check the PDF file to see if this junk is there as well, but it opens fine.

In the log checking blog post I linked to, this problem is avoided because when the log checker finds errors in the log, it does not stream the (rtf/pdf/whatever) report back to the user, and instead gives them a custom error report.

--Q.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
lacrefa
Calcite | Level 5

Dear all,

Which version of SAS BI plateform used ?

Because with an colleague, we developp a Stored process that produc a report with PDF output format. During this task, we used this _degug=139, we do not see the output with the format,all binaire information of th pdf file is display in the output html file.

Which option did you define to define the output : stpsrv_header(Content-type,application/pdf) and stpsrv_header('Content-disposition',"attachment;filename=myreport.pdf") ;

can have a look on this link :

http://support.sas.com/rnd/itech/doc9/dev_guide/stprocess/srvhead.html

I find an other linked : http://www.bi-notes.com/2012/07/stored-process-ignore-log-your-own-peril/, this link seems to be the best way to explain the simple way outside more knowledge of SAS components.

Quentin
Super User

@lacrefa, So glad you found my blog post helpful:

I find an other linked : http://www.bi-notes.com/2012/07/stored-process-ignore-log-your-own-peril/, this link seems to be the best way to explain the simple way outside more knowledge of SAS components.

That was my first post for www.bi-notes.com (actually my first blog post anyhwere), I'm hoping to do a few more soon.

I am using 9.3, and get the same results as you do.  If I have a stored process that returns a pdf, and call it from SPWA with _debug=131, I see the binary representation of the pdf file in the browswer, followed by the log.  It does not prompt me to open/save the pdf.

Using PROC PRINTTO to send the log to a file works well for me when I'm  developing stored processes.  Our SAS server runs on a linux box, and I usually develop from Windows.  I use Ultradedit.  It can open the log file from the server and keep it open.  I can then run the stored process, and refresh the file in ultraedit to see the new log.  If I write the log file to somewhere accesible via SAMBA, Ultraedit will automatically refresh it when it changes.

And for some production stored processes, I write the log to a file named "%sysfunc(compress(%scan(&_program,-1,/)_&_UserName._%sysfunc(datetime(),b8601dt))).log" So the name of the log file is the stored process name, name of user who called it, and a time stamp.

--Q.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
lacrefa
Calcite | Level 5

Dear Quentin,

As Admistrator of SAS BI plateform I can say, your post is a good job to provide right way for developpers.

It depends how your administrator configures your Logical Stored Process Server  (Stored process or Worksapce server). If some options are omit or activated your solution could not work. For example if the nosyntaxcheck is not used, the reference to all External files will be lost. By default it is not the case for plateform SAS 9 TS2MX but this option must be activated in SAS 9.1.3 by the administrator or in your defintion of STP.

For the moment I could say how is configure by default the logical STP server inSAS9.3 ( in 2-3 month perhaps).

Best regards.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 12 replies
  • 5447 views
  • 0 likes
  • 5 in conversation