<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add a Hyperlink for each data row when outputting data using a PUT statement within ODS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540027#M148913</link>
    <description>&lt;P&gt;Hi ChrisNZ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output that I'm going for is pictured below. Each observation and it's associated variables are formatted into a paragraph-like form. What I am trying to do is make the link in line 2 of each paragraph to be hyperlinked and have the hyperlinked file open in a new window/tab.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Output.PNG" style="width: 327px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27637i37E64CB1DCAA9FA0/image-dimensions/327x237?v=v2" width="327" height="237" role="button" title="Output.PNG" alt="Output.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is functioning code to get the above output (obviously you will have to replace the file paths with ones that work for you). I prefer html output b/c hyperlinks within pdfs seems to open hyperlinks in the same window, replacing the original output file you were on which is not what I want. I'd prefer if the hyperlinks open in new windows. Thanks so much for you help on this!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1; infile datalines dlm='#';
input FilePath &amp;amp; $28. ObservationID Gender $ Age Race &amp;amp; $17. PlaceOfInjury &amp;amp; $20. InjuryDate &amp;amp; $10. City &amp;amp; $20. State &amp;amp; $20. Narrative &amp;amp; $50.;
datalines;
C:\Users\Documents\Accidents# 123456# Male# 43# African American# Home# 2016-99-99# Unknown City# Unknown State# Male was injured in his home.#
C:\Users\Documents\Accidents# 123457# Female# 35# African American# Public Facility# 2019-99-99# Unknown City# Unknown State# Female was injured at a Public Facility.#
;
run;

/*OUTPUT DATA AS PDF*/
options pagesize=32767; /*page size set to max to avoid title repeating throughout and breaking up the output*/
   ods listing close;
   ods html file="C:\Users\Documents\Accidents\Ouput.html"; *nobookmarkgen style=styles.listing;

   data _null_;
      set test1;
      file print ps=54 ls=97;
      HyperLink = FilePath||'\'||substr(InjuryDate,1,4)||'\'||strip(ObservationID)||'.pdf';
  	put / @1 _n_ @10 'Observation: ' ObservationID /
		@1 Hyperlink  /
		@1 'Age: ' Age 'Sex: ' Gender 'Race:' Race /
		@1 ' Place of Injury: ' PlaceOfInjury /
		@1 '     Injury Date: ' InjuryDate /
		@1 ' Injury Location: ' City', ' @34 State /
		@1 '       Narrative: ' Narrative//;
   run;
   quit;

   ods html close;
   ods listing;

%put _user_; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2019 13:59:49 GMT</pubDate>
    <dc:creator>lynagh18</dc:creator>
    <dc:date>2019-03-04T13:59:49Z</dc:date>
    <item>
      <title>Add a Hyperlink for each data row when outputting data using a PUT statement within ODS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/539365#M148598</link>
      <description>&lt;P&gt;I am using ODS (prefer pdf or html, but can do rtf as well)&amp;nbsp; to output data and using a PUT statement within the ODS to the output information for each observation as a paragraph rather than listing the data in a table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of the PUT statement within the ODS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; ods pdf file="&amp;amp;path.pdf";
 ods escapechar="^";
 data _null_;
   set have;
      file print ps=54 ls=97;
      ods text="^{style[font_face='calibri' fontsize=11pt just=center fontweight=bold] Report Header}";
	  hyperlink = 'C:\Documents'||substr(String,1,2)||'\'||substr(String,3,8)||'.pdf';&lt;BR /&gt;          put / '@1 DocumentNumber $10. /
		@1 hyperlink  /
		@1 ' Narrative: ' IncidentNarrative//;
  run;
  quit;
ods pdf clos&lt;BR /&gt;ods listing;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each paragraph in the output will be all the called variables for one observation/row. In each paragraph for each observation/row, I need to include a hyperlink that is unique for that one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been struggling with this for a long time and am really hoping someone can help me figure this out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your time,&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2019 16:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/539365#M148598</guid>
      <dc:creator>lynagh18</dc:creator>
      <dc:date>2019-02-28T16:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Add a Hyperlink for each data row when outputting data using a PUT statement within ODS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/539483#M148650</link>
      <description>&lt;P&gt;I am unsure that I understand your need.&lt;/P&gt;
&lt;P&gt;1. Can you provide running code please?&lt;/P&gt;
&lt;P&gt;2. Can you provide a screenshot if the desired result (taken from a mock word processor document if you want)?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2019 20:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/539483#M148650</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-02-28T20:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Add a Hyperlink for each data row when outputting data using a PUT statement within ODS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/539496#M148661</link>
      <description>&lt;P&gt;I &lt;STRONG&gt;think&lt;/STRONG&gt; that what you are attempting is possible with Proc ODSTEXT. Note that is a specific proc not the ODS TEXT statement.&lt;/P&gt;
&lt;P&gt;The procedure will take a data set as input, allows expressions in the P (stands for paragraph) statement and allows style overrides.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2019 21:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/539496#M148661</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-28T21:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Add a Hyperlink for each data row when outputting data using a PUT statement within ODS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540027#M148913</link>
      <description>&lt;P&gt;Hi ChrisNZ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output that I'm going for is pictured below. Each observation and it's associated variables are formatted into a paragraph-like form. What I am trying to do is make the link in line 2 of each paragraph to be hyperlinked and have the hyperlinked file open in a new window/tab.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Output.PNG" style="width: 327px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27637i37E64CB1DCAA9FA0/image-dimensions/327x237?v=v2" width="327" height="237" role="button" title="Output.PNG" alt="Output.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is functioning code to get the above output (obviously you will have to replace the file paths with ones that work for you). I prefer html output b/c hyperlinks within pdfs seems to open hyperlinks in the same window, replacing the original output file you were on which is not what I want. I'd prefer if the hyperlinks open in new windows. Thanks so much for you help on this!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1; infile datalines dlm='#';
input FilePath &amp;amp; $28. ObservationID Gender $ Age Race &amp;amp; $17. PlaceOfInjury &amp;amp; $20. InjuryDate &amp;amp; $10. City &amp;amp; $20. State &amp;amp; $20. Narrative &amp;amp; $50.;
datalines;
C:\Users\Documents\Accidents# 123456# Male# 43# African American# Home# 2016-99-99# Unknown City# Unknown State# Male was injured in his home.#
C:\Users\Documents\Accidents# 123457# Female# 35# African American# Public Facility# 2019-99-99# Unknown City# Unknown State# Female was injured at a Public Facility.#
;
run;

/*OUTPUT DATA AS PDF*/
options pagesize=32767; /*page size set to max to avoid title repeating throughout and breaking up the output*/
   ods listing close;
   ods html file="C:\Users\Documents\Accidents\Ouput.html"; *nobookmarkgen style=styles.listing;

   data _null_;
      set test1;
      file print ps=54 ls=97;
      HyperLink = FilePath||'\'||substr(InjuryDate,1,4)||'\'||strip(ObservationID)||'.pdf';
  	put / @1 _n_ @10 'Observation: ' ObservationID /
		@1 Hyperlink  /
		@1 'Age: ' Age 'Sex: ' Gender 'Race:' Race /
		@1 ' Place of Injury: ' PlaceOfInjury /
		@1 '     Injury Date: ' InjuryDate /
		@1 ' Injury Location: ' City', ' @34 State /
		@1 '       Narrative: ' Narrative//;
   run;
   quit;

   ods html close;
   ods listing;

%put _user_; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 13:59:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540027#M148913</guid>
      <dc:creator>lynagh18</dc:creator>
      <dc:date>2019-03-04T13:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Add a Hyperlink for each data row when outputting data using a PUT statement within ODS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540312#M149025</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods html file="%sysfunc(pathname(WORK))\Output.html"; 
data _null;
  set HAVE;
  file print;
  HYPERLINK = cats(FILEPATH, '\', put(INJURYDATE,$4.), '\', OBSERVATIONID, '.pdf');
  HYPERLINK = cats('&amp;lt;a href="',  HYPERLINK,  '" target="_blank"&amp;gt;', HYPERLINK, '&amp;lt;/a&amp;gt;');
  put / @1 _N_ @10 'Observation: ' OBSERVATIONID    
      / @1 HYPERLINK                                
      / @1 'Age: ' AGE  'Sex: ' GENDER             
      / @1 ' Place of Injury: ' PLACEOFINJURY       
      / @1 '     Injury Date: ' INJURYDATE          
      / @1 ' Injury Location: ' CITY ', ' @34 STATE 
      / @1 '       Narrative: ' NARRATIVE         
      /;
run;
ods html close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 548px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27663i514F793DBAB36171/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 09:46:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540312#M149025</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-03-05T09:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Add a Hyperlink for each data row when outputting data using a PUT statement within ODS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540442#M149092</link>
      <description>&lt;P&gt;Thank you so much ChrisNZ!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This does work for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My original syntax for the hyperlink tags was not correct, but there was another seemingly unrelated issue that was preventing the hyperlinks from working. When I specified the page size (ps=) and line size (ls=) for the &lt;FONT color="#0000FF"&gt;File Print&lt;/FONT&gt; statement, the hyperlink would be output as the literal string with the tags around it (e.g. &amp;lt;a href = link string&amp;gt; &amp;lt;/a&amp;gt;) and wouldn't actually link/redirect to the other file. When I don't specify the page and line size for the &lt;FONT color="#0000FF"&gt;File Print&lt;/FONT&gt; statement, the hyperlink is output and redirects as desired.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 14:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540442#M149092</guid>
      <dc:creator>lynagh18</dc:creator>
      <dc:date>2019-03-05T14:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add a Hyperlink for each data row when outputting data using a PUT statement within ODS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540444#M149093</link>
      <description>&lt;P&gt;Thanks for the response ballardw. I'm not quite sure what you mean, so I can't comment on whether this works or not, but given that ChrisNZ liked your response, I'm assuming yours is a valid solution. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 14:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-Hyperlink-for-each-data-row-when-outputting-data-using-a/m-p/540444#M149093</guid>
      <dc:creator>lynagh18</dc:creator>
      <dc:date>2019-03-05T14:07:02Z</dc:date>
    </item>
  </channel>
</rss>

