BookmarkSubscribeRSS Feed
sasjourney
Calcite | Level 5

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

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

sasjourney
Calcite | Level 5

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

Ksharp
Super User
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

sasjourney
Calcite | Level 5

Hi Xia,

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

Thanks

Ksharp
Super User

Contact with SAS Technical Support .

OR

Cynthia@sas might give you an answer.

Xia Keshan

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2514 views
  • 1 like
  • 3 in conversation