BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9
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;
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
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]
Filipvdr
Pyrite | Level 9
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) || '' ;
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 908 views
  • 0 likes
  • 2 in conversation