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" target="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?
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.
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.
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 " 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.
@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 " 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 " if you wanted " ?
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.
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.