BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
eshupp
Obsidian | Level 7

I am trying to add a TARGET= to a URL generated in a PROC REPORT with CALL DEFINE so that the generated hyperlink works correctly in a framed environment.  There does not appear to be documented way to do this that I have found.  I have seen some references to modifying the style template but have not found any working examples.  I tried fooling the system by including double quotes in my CALL DEFINE to extend the generated HREF which almost worked, but the actual html converted the buried double quotes to " which did not work when displaying the page.

 

compute link;
  href=cat("&htmlbody..html#",trim(scan(path,-1,'\')),'" target="body');
  call define(_col_,'URL',href);
endcomp;

 

Results in this HTML:

 

<tr>
<td class="l data" style=" border-width: 0px;"><a href="BODY.html#Report#16&quot; target=&quot;body">Messages by Severity</a>
</td>
</tr>

 

which does not work properly.  Any suggestions on how I can generate a proper target="body" with CALL DEFINE?

1 ACCEPTED SOLUTION

Accepted Solutions
eshupp
Obsidian | Level 7

Thanks to Chevell at SAS support the solution to this is adding HREFTARGET= to the PROC REPORT STYLE(COLUMN) parameter:

 

proc report data=reportdata
style(report)={just=c frame=box}
style(header)={frame=void}
style(column)={frame=void hreftarget="_blank"}
nowd;

href=catt("c:\output\body.html#",name);                                                                                                

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

endcomp;                           

run;

 

This added the target="_blank" to the generated anchor.                                                                                                     

View solution in original post

6 REPLIES 6
ballardw
Super User

I would suggest showing an example with no macro variables or function calls needed: i.e. a fixed URL before attempting to get a more complex example working.

 

From what you show for the resolved path I strongly suspect that your macro variables aren't what you want.

eshupp
Obsidian | Level 7

Thanks for your comment. 

I can tell that the macro variables are resolving properly from the generated HTML in the post.  Also, when I edit the generated HTML output file and change all &quot; strings to " (double quotes) the page works properly.  My assumption is that this can be solved with a PROC TEMPLATE alteration of the style, or an additional CALL DEFINE to reset a style parameter.  I just don't know which parameter to override.

Tom
Super User Tom
Super User

@eshupp wrote:

Thanks for your comment. 

I can tell that the macro variables are resolving properly from the generated HTML in the post.  Also, when I edit the generated HTML output file and change all &quot; strings to " (double quotes) the page works properly.  My assumption is that this can be solved with a PROC TEMPLATE alteration of the style, or an additional CALL DEFINE to reset a style parameter.  I just don't know which parameter to override.


Huh?  Why did you output &quot; if you wanted " ?

 

eshupp
Obsidian | Level 7
I did not, ODS converted my " to &quot; when it generated the HTML.
Tom
Super User Tom
Super User

Because it is interpreting ' target="body"' as part the URL. 

 

You are passing just the content of the HREF= option of the <a> tag.  I do not see any method to modify the value of the target= option of the <a> tag.

eshupp
Obsidian | Level 7

Thanks to Chevell at SAS support the solution to this is adding HREFTARGET= to the PROC REPORT STYLE(COLUMN) parameter:

 

proc report data=reportdata
style(report)={just=c frame=box}
style(header)={frame=void}
style(column)={frame=void hreftarget="_blank"}
nowd;

href=catt("c:\output\body.html#",name);                                                                                                

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

endcomp;                           

run;

 

This added the target="_blank" to the generated anchor.                                                                                                     

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 497 views
  • 0 likes
  • 3 in conversation