The SAS Output Delivery System and reporting techniques

Links in ODS

Reply
Contributor
Posts: 43

Links in ODS

Hello all,

I was trying to create links internally based on the values of a variable but wasn't able to create a link when the word I wanted to create a link for is a string.

For example, say I have a variable "Text" as below and have information on different pages of a PDF document for each of the values.

obs Text

1     Apples

2     Grapes

3     Apples Oranges

4     Apples Oranges Grapes

5     Apples are good

I was able to create links when there is only one value (Apples or Grapes) but wasn't successful in creating links when there is some other text associated with the text I wanted to create the link or to create different links for each valid word (different links for Apples, Oranges in obs 3 or link to Apples in obs 4). Can someone please help me on how to get this right.

Thanks

Super User
Super User
Posts: 7,997

Re: Links in ODS

Posted in reply to sasjourney

Mmm, from experience links are a pain.  I had a discussion on this type of thing some time back: https://communities.sas.com/thread/42000

I would assign each link a unique identifier in a datastep and use that rather than just text, e.g. L0001 = Apples, L0002=Grapes etc.

Contributor
Posts: 43

Re: Links in ODS

Thanks for the reply RW, I was using text as anchor as discussed in your posted thread below but that seems not working. I will try using mix of numbers and see if that works.

Thanks

Super User
Posts: 10,046

Re: Links in ODS

Posted in reply to sasjourney
data have;
input obs Text & $400.;
cards;
1     Apples
2     Grapes
3     Apples Oranges
4     Apples Oranges Grapes
5     Apples are good
;
run;
data temp(drop=i temp text);
 set have;
 length t temp $ 400;
 do i=1 to countw(text);
  temp=scan(text,i);
  if temp='Apples'     then temp=catx(' ','~S={url="http://www.wwe.com"}',temp);
   else if temp='Oranges'     then temp=catx(' ','~S={url="http://www.sas.com"}',temp);
  t=catx(' ',t,temp);
 end;
run;
ods listing close;
ods html file='x.html' style=sasweb;
ods escapechar='~';
proc report data=temp nowd ;run;
ods html close;
ods listing;


Xia Keshan

Contributor
Posts: 43

Re: Links in ODS

Hi Xia,

Your example only works for HTML output but not for PDF.

Thanks

Super User
Posts: 10,046

Re: Links in ODS

Posted in reply to sasjourney

Contact with SAS Technical Support .

OR

Cynthia@sas might give you an answer.

Xia Keshan

Ask a Question
Discussion stats
  • 5 replies
  • 547 views
  • 1 like
  • 3 in conversation