The SAS Output Delivery System and reporting techniques

Proc Report compute before _page_ question

Reply
Regular Contributor
Posts: 229

Proc Report compute before _page_ question

Hello,
is it possible to add some style elements to one line? Or place a link on one element?

/* Text before each table */
compute before _page_ / style={just=l};
text1 = "Lot_Id: " || strip(Lot_Id) || " Facility: " || strip(Facility) || "" ;
text2 = "Holdcode: " || strip(Holdcode) || " Holdnote: " || strip(Holdnote) || "" ;
text3 = "Route: " || strip(route) || " ProcessEngineer: " || strip(ProcessEngineer) || " BatchEngineer: " || strip(BatchEngineer) || "" ;
text4= "Days At Operation: " || strip(put(DaysOper,6.2)) || "" ;
text5= "Arrival Date: "|| strip(put(Datim,datetime21.)) || "" ;
text6= "Operations Last 24hrs: " || strip(put(oper24,6.2)) || " Last 48hrs: " || strip(put(oper48,6.2)) || "" ;
line text1 $;
line text2 $;
line text3 $;
line text4 $;
line text5 $;
line text6 $;
endcomp;
SAS Super FREQ
Posts: 8,743

Re: Proc Report compute before _page_ question

Hi:
If you investigate the use of ODS ESCAPECHAR capability, you will discover that you can use "in-line formatting" to alter the output in a single line, for example, making several words in a string red and making other words cyan. There have been many previous forum postings on using ODS ESCAPECHAR.

When you use ODS ESCAPECHAR, you specify style attributes and their values to override what is specified in the SAS style template. This applies to most commonly used attributes like color (or foreground), backgroundcolor (or background), font_face, font_size, etc. In addition, there is another style attribute (the URL attribute) that you can set as shown in the program below.

In addition to using ODS ESCAPECHAR to insert a URL, if you are interested in HTML-based destinations, such as ODS HTML, then you could code an HTML <A> tag directly in your LINE as shown. This technique may not work in other destinations -- since not all destinations are HTML-based and so you might need to use URL= for other destinations.

In the code below, TEXT1, TEXT2 and TEXT3 show the use of color and font changes. TEXT4, TEXT5 and TEXT6 show the use of different ways to create URL links.

There are 2 forms of ODS ESCAPECHAR syntax: the original syntax and the newest (function-like) syntax. The ESCAPECHAR itself is declared in the ODS ESCAPECHAR statement. Then, after the character has been defined (in this case, ^), you can use it. The ESCAPECHAR+S={attr=val} form is the original form of syntax and the ESCAPECHAR+{style[attr=val] string} syntax is the newer form of syntax. If you have SAS 9.2, you should use the newer form of syntax, if you have SAS 8 or SAS 9.1, then you use the original form of syntax.

cynthia
[pre]

title;
ods listing close;
ods html file='c:\temp\showstyle.html' style=sasweb;
ods escapechar='^';

proc report data=sashelp.class(obs=3) nowd;
column name age height weight sex;

compute before _page_ / style={just=l protectspecialchars=off};
dateval = today();
somenumber = 888.77;
text1 = "^{style[font_size=14pt color=blue]Lot_Id: 123456 Facility: ABCDEFG}";
text2 = "^S={color=green}Holdcode: " || strip(name) || "^S={color=black} Holdnote: " || strip(sex);
text3= "^{styleArrival Date: } ^{style"|| strip(put(dateval,worddate21.))|| "}";
text4 = '^{style[url="http://www.google.com"]Route: 1234567 ProcessEngineer: }' || strip(name) || " BatchEngineer: " || strip(name) ;
text5= '^S={url="http://www.sas.com"}Days At Operation: ' || strip(put(somenumber,6.2)) ;
text6= "<div><a href='http://www.setgame.com'>Link For HTML only</a></div>" ;
line text1 $;
line text2 $;
line text3 $;
line text4 $;
line text5 $;
line text6 $;
endcomp;
run;
ods html close;
[/pre]
Regular Contributor
Posts: 229

Re: Proc Report compute before _page_ question

ok thanks, i wasn't sure if it would work with escapechar

now i'm just having this quoting problem

text1 = '^{style[url="http://wiksas.imec.be:8080/SASStoredProcess/do?_program=/Samples/SP_ShortTermScheduleFast&lotnumber=' || compress(Lot_Id) || '&_odsstyle=meadow"]Lot_Id: }' || strip(Lot_Id) || '(' || strip(Priority) || ') Facility:' || strip(Facility) || '' ;
SAS Super FREQ
Posts: 8,743

Re: Proc Report compute before _page_ question

You don't show an error message. How do you know it's a quoting problem??

You may want to refer to this documentation on chaining stored processes:
http://support.sas.com/documentation/cdl/en/stpug/61271/HTML/default/viewer.htm#datapass.htm
http://support.sas.com/documentation/cdl/en/stpug/61271/HTML/default/viewer.htm#webinput.htm

And note the ways in which you need to "protect" the & and other special characters found in a URL. If you continue to have issues with building a URL, you may want to work with Tech Support.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 168 views
  • 0 likes
  • 2 in conversation