BookmarkSubscribeRSS Feed
Elliott
Obsidian | Level 7

I posted the other day about creating hyperlinks with ods and proc report.  I was able to create the hyperlink and it is in the right most column of my report.   The user does not want that extra column and asked if I could have the hyperlink embedded in the report_number variable.  Can that be done? can I assign the variable value to the link and hide the column with the actual full link information?

 

Thanks,

Elliott

12 REPLIES 12
Reeza
Super User

Yes, the formula part takes one part as text and one as the link. 

Set them appropriately and you should be fine. 

 


@Elliott wrote:

I posted the other day about creating hyperlinks with ods and proc report.  I was able to create the hyperlink and it is in the right most column of my report.   The user does not want that extra column and asked if I could have the hyperlink embedded in the report_number variable.  Can that be done? can I assign the variable value to the link and hide the column with the actual full link information?

 

Thanks,

Elliott


 

Elliott
Obsidian | Level 7
I don't know how.

each row will have a different report number that I need to assign to the link.

this is the code I have now that creates the report:

proc report nofs data=work.zero_vol1 list;

title "No Error Volume";

column DT REPORT_NUMBER REPORT_ID ERRS VOL COMMENTS LINK;

define link /display;

compute link ;

href=trim(link)||".html";

call define(_col_, "URL", href);

endcomp;

run;


Reeza
Super User

In your previous question, a suggestion was made by @SuryaKiran to use a formula instead. That is the approach you can use if the URL is different than the text. 

 

https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-hyperlinks/m-p/491711/highlight/true#...

 

 

Cynthia_sas
SAS Super FREQ

Hi:

  This approach worked for me. I just used NOPRINT to hide the computed link and then used the CALL DEFINE on NAME instead.

ods html path='c:\temp' (url=none) file='hidelink.html';
ods excel file='c:\temp\hidelink.xlsx';
proc report data=sashelp.class;
  column name age sex height href;
  define name / display;
  define href / computed noprint;
  compute href / character length=100;
    href = catt('https://nameberry.com/babyname/',name);
	call define('name','url',href);
  endcomp;
run;
ods _all_ close;

Cynthia

Elliott
Obsidian | Level 7

Cynthia, this has been helpful and I am getting the link on the correct variable but the link goes to C:\...\Local\Microsoft\Windows\Temporary\Internet Files\Content,Outlook\BSC00BHK\  

 

It did not pick up the string from the LINK variable.  The value in the LINK variable is the full address to the SharePoint folder starting with https://

 

this is my code:

proc report nofs data=work.zero_vol1 list;

    title "Reports with No Error Volume";

   column DT REPORT_NO REPORT_ID ERRS VOL COMMENTS LINK;

   define DT / display;

   define REPORT_NO / display;

   define REPORT_ID / display;

   define ERRS / style(column)=[tagattr='format:0'];

   define VOL / style(column)=[tagattr='format:#,##'];

   define link /computed noprint;

   compute link ;

          href=catt(link,'.html',REPORT_NUMBER);

    call define('REPORT_NUMBER','url', href);

    endcomp;

   run;

 

 

 

I also get a note in the log that says:

 

NOTE:  The computed variable LINK is also a data set variable.

NOTE:  The output might not be as expected.

 

I am not sure if that is important on not.

 

Thank you very much for your help

Elliott

Reeza
Super User

Can you show a screenshot of what you're seeing in Excel?

Elliott
Obsidian | Level 7

IMG_3524.jpgwhen I hover over the link this is what it shows

Reeza
Super User
  1. Does @Cynthia_sas code work for you as expected?
  2. Did you try changing the variable names (link) to avoid the NOTES in the log?
  3. What does the URL look like in the variable link, and how does it look after concatenated?

 

I tested this with an HTTPS link to my Sharepoint site and it worked fine - using SAS 9.4 TS1M5. 

 


@Elliott wrote:

IMG_3524.jpgwhen I hover over the link this is what it shows


 

 

 

 

Elliott
Obsidian | Level 7

Cynthia's did make the link on the correct variable, and hid the  actual variable that had the full http path.  but the link that got created on the report no variable was to that location in the screen shot, not the sharepoint link.

 

I did try to change the variable name but the result was not correct.. 

 

the url looks like https://...just like any link to a sharepoint site.

 

I had this working with the full link on the right but the user does not want it that way, that is why I am trying to assign the hyperlink to the report no variable.

Reeza
Super User

I get that. Can you post some fully reproducible code to see what you're getting? I can't run your code because no data. Mocking up some data would help with testing.

 

The only difference between Cynthia's code and yours that I see is that link is already a variable and she creates a new one, so I wonder if that's the issue. I wonder if it's setting link to missing which is then ., which then pushes it to your working directory, which is what that path looks like. 

 

 

Elliott
Obsidian | Level 7

I kept playing with it, I have it working now.. the only thing is I would now like the report no to be in blue font with an underline so it is obvious it is a link.. how is that done?  I assume it is with a style attribute of some kind.

 

Thanks, this is awesome

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 12 replies
  • 3703 views
  • 2 likes
  • 3 in conversation