2

The case is: The target URL is for example "https://stackoverflow.com/". I have a data set with Ids. If I put "https://stackoverflow.com/"+"ID" it is the final hyperlink, which leads to the final webpage.

How to create the list id Hyperlinks (data step) with URLs in which the name of every cell will be "ID" (after proc print), and when I click the hyperlink, it addresses me to "https://stackoverflow.com/3453456" Thanks!

Here is my code:

%let url = https://stackoverflow.com/;

Data final_table;
set table_id;
Link='<A' || compress("HREF=""&url||">(ID) </A>;run;

but it goes with the error

** I did like Dompazz said, here is the result:

enter image description here

enter image description here

Community
  • 1
  • 1

2 Answers2

3

It depends on the output location. HTML, this works, putting a link in the table.

data test;
link = "<a href='http://www.google.com'>Google</a>";
run;

ods html body="c:\temp\test.htm";
proc print data=test;
run;
ods html close;

But it fails in a PDF, just showing the text of the link.

ods pdf body="c:\temp\test.pdf";
proc print data=test;
run;
ods pdf close;

For PDFs, the code is URL=.... So this generates a PDF where I can click on Google and open http://www.google.com

ods escapechar="^";
data test;
link = "^S={URL='http://www.google.com'}Google";
run;

ods pdf body="c:\temp\test2.pdf";
proc print data=test;
run;
ods pdf close;
DomPazz
  • 12,415
  • 17
  • 23
1

I am not sure what error you have got, but you have some problems with your syntax when building your URL. See the working code below that generates one listing with URL to this question:

%LET url=http://stackoverflow.com/questions/; 
data test;
ID = "34266798"; 
Url_Link = '<A '|| compress("HREF=&url")||ID||'> ID </A>'; 
RUN; 

PROC SQL;
    CREATE VIEW WORK.SORTTempTableSorted AS
        SELECT T.Url_Link
    FROM WORK.TEST as T
;QUIT;

PROC PRINT DATA=WORK.SORTTempTableSorted
    OBS="Row number"
    LABEL
    ;
    VAR Url_Link;
RUN;
Vasilij Nevlev
  • 1,449
  • 9
  • 22
  • Could you give more detail how it doesn't meet your expectation? When you click on "URL", it leads you to this quesion which is what you were trying to achieve in your code, right? Or do you need to see the full URL instead of "URL"? – Vasilij Nevlev Dec 14 '15 at 16:22
  • I neet an URL named for ex. "The link" when you click it, browser opening an URL: http://stackoverflow.com/questions/45798 – Donald William Glossfield Dec 14 '15 at 16:30
  • Huh, I was expecting that you have a default HTML ODS output open. My assumption was that your PROC PRINT already printing an HTML output. – Vasilij Nevlev Dec 15 '15 at 09:22