BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi
i am trying to add few "Buttons" to store process output using the code below.
i am getting an error as below.

ERROR 180-322: Statement is not valid or it is used out of proper order.


My code :

%STPBEGIN;
**** Clear all the previous datasets in work library ****;
proc datasets kill nolist;
quit;

ODS PATH work.templat(update) sasuser.templat(read)
sashelp.tmplmst(read);

proc template;
define style styles.test;
parent=styles.default;
style table from output /
posthtml='

onclick=javascript:window.open("http://www.sas.com")>

onclick="history.back()">

onclick="history.forward()">

onclick=javascript:window.close()>

onclick=javascript:window.print()>
' ;
end;
run;

%let mystyle=styles.test;

% Let _ODSSTYLE =&mystyle;

title;
footnote;

proc print data=sashelp.class;
run;


%STPEND;


Would appreciate your help on this.
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
This technique to add a button to ODS HTML output is a technique that generally works in SAS/ODS outside the context of the Enterprise Intelligence Platform.

Whether it will work -inside- the Enterprise Intelligence Platform as part of stored process results depends on 1) what client application you are using to execute or request the stored process application to run; 2) whether the client application knows what to do with the JavaScript button and the onclick, etc and 3) (related to 2) whether the client application can even handle HTML results, including an HTML <input> tag. For example, Microsoft PowerPoint does not receive HTML results from a stored process. The only kind of output that PowerPoint can receive is SASReport XML format. Microsoft Word can receive HTML results, but I do not know whether Word would handle JavaScript or a button.

This technique might work if you were going to use the SAS Information Delivery Portal or the Stored Process Web Application or a custom front end to deliver HTML results from a stored process. However, in addition to needing answers to the above questions, someone needs to actually see the place in your code where the error message is getting issued.

The people best suited to help you with this error message and with the development of this stored process are the people in SAS Tech Support.

cynthia
deleted_user
Not applicable
Hi Cynthia
Thanks for your reply.
i am calling the stored process through web only.

Only problem in the code is when i call for a custom style. if i remove the custom style this works fine.

is there anything needed to add custom style details when using ODS Listing or webout?

Thanks
Cynthia_sas
SAS Super FREQ
Hi:
I expected this to work using the Stored Process Web Application. But, when I tried your stored process using the Stored Process Web Application, I got this error message in the log:
[pre]
14 + style table from output /
WARNING: Truncated record.
[/pre]

which indicates to me that your posthtml string is too long. And your style template never got put into the WORK location because of the error.

One trick I frequently use with long text strings is to let the macro processor assemble them (even if I can't send the whole long string to the compiler in open code, the macro processor can pass quite long "assembled" strings to the SAS compiler):
[pre]

*ProcessBody;
%global _ODSSTYLE _ODSSTYLESHEET mystyle;

ODS PATH work.templat(update)
sasuser.templat(read)
sashelp.tmplmst(read);

%let p1 = <input type='button' value='Open SAS' onclick=javascript:window.open('http://www.sas.com')> ;
%let p2 = <input type='button' value='BACK' onclick='history.back()'> ;
%let p3 = <input type='button' value='FORWARD' onclick='history.forward()'> ;
%let p4 = <input type='button' value='CLOSE WINDOW' onclick=javascript:window.close()> ;
%let p5 = <input type='button' value='PRINT PAGE' onclick=javascript:window.print()> ;

proc template;
define style styles.test;
parent=styles.default;
style table from output /
posthtml= "&p1.&p2.&p3.&p4.&p5";
end;
run;

%let mystyle=styles.test;
%Let _ODSSTYLE =&mystyle;
%let _odsstylesheet=;
title;
footnote;

%stpbegin;
proc print data=sashelp.class;
title "using style &_ODSSTYLE";
run;
%stpend;
[/pre]

This stored process worked for me using the Stored Process Web Application. Note how I changed all the double quotes in the strings to single quotes. Most versions of HTML will accept single quotes for tag attributes, even though the W3C recommends double quotes. This simplifies the code for me and means that I don't have to use macro quoting functions to protect the double quotes in the POSTHTML attribute. Note also that I did NOT put the proc template inside the %STPBEGIN/%STPEND "sandwich" -- since the proc template is not producing any streaming results, it can be before %STPBEGIN.

If you need more help with your JavaScript or with using (or NOT using) cascading style sheets, you should contact Tech Support.

cynthia

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
  • 3 replies
  • 1455 views
  • 0 likes
  • 2 in conversation