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;

 

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: 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.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: 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.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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