BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hi,

 

I'm using ODS text in SAS 9.3 to write some text to an html file, and want to make a link that will look like:

  a href="www.sas.com?&Ion=Ca++"

Because I have those silly plus signs to deal with, I need to URL encode them to:

  a href="www.sas.com?&Ion=Ca%2B%2B"

 

But when I do this with ODS text I end up with no % signs in the html file, I get:

  a href="www.sas.com&Ion=Ca2B2B"

Which doesn't work at all. 

 

Below code I try both hard coding the %2B and using URLENCODE() inline.  Both work in the title statement but not ODS text. 

 

What am I missing? Shouldn't this work?

 

 

ods html file="d:\junk\myhtml.html";

title1 "<a href=""http://www.sas.com?%nrstr(&Ion=)%sysfunc(URLencode(Ca++))"")> Title1 link works</a>";
title2 "<a href=""http://www.sas.com?%nrstr(&Ion=)Ca%2B%2B"")> Title2 link works</a>";
ods text="<a href=""http://www.sas.com?%nrstr(&Ion=)%sysfunc(URLencode(Ca++))"")> ODS Text1 link broken</a>";
ods text="<a href=""http://www.sas.com?%nrstr(&Ion=)Ca%2B%2B"")> ODS Text2 link broken</a>";

proc print data=sashelp.class (obs=1);
run;

ods html close;

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Quentin,
How about using URL Style ?




%let ionlist=Ca++|Na+;
%let I=%nrstr(http://www.sas.com?&Ion=)%sysfunc(URLencode(&ionlist));
%put &i ;

ods escapechar='~';
ods text="~S={url='&i'}ODS Text2 link broken";


proc print data=sashelp.class;
run;



View solution in original post

4 REPLIES 4
ballardw
Super User

ods text="<a href=""http://www.sas.com?%nrstr(&Ion=)Ca%%2B%%2B"")​> ODS Text2 link broken</a>";

 

Quentin
Super User

Thanks @ballardw that works.  Curious why the extra % is needed in ODS Text? 

 

And more importantly, is there any way to get this working with URLENCODE()?   

 

Currently I've get a data-generated macro variable &ionList with value like : Ca++|Na+ 

which I URLENCODE().  I suppose I could double up the % signs myself like:

 

%let ionlist=Ca++|Na+;
%put %sysfunc(transtrn(%sysfunc(URLencode(&ionlist)),%,%%));

 

But feels silly.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
Ksharp
Super User
Quentin,
How about using URL Style ?




%let ionlist=Ca++|Na+;
%let I=%nrstr(http://www.sas.com?&Ion=)%sysfunc(URLencode(&ionlist));
%put &i ;

ods escapechar='~';
ods text="~S={url='&i'}ODS Text2 link broken";


proc print data=sashelp.class;
run;



Quentin
Super User

Thanks @Ksharp, looks like using URL style the % signs don't disappear.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 3063 views
  • 4 likes
  • 3 in conversation