<?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: Inserting additional characters into a column in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44925#M5170</link>
    <description>Hi:&lt;BR /&gt;
  This is something that is relatively easy to do with PROC REPORT. You have 2 ways to do it. You can either do it in a user-defined format and then use the URL= suboption to build the link. Or, you can use a CALL DEFINE statement with the URL attribute as argument 2 to the CALL DEFINE statement.&lt;BR /&gt;
&lt;BR /&gt;
  These 2 methods take advantage of the fact that ODS knows how to build an anchor tag. So you do not have to code the entire URL &amp;lt;A&amp;gt; tag. ODS does that for you.&lt;BR /&gt;
&lt;BR /&gt;
  Both methods are shown in the program below. (the URL= style attribute method will also work with PROC PRINT and PROC TABULATE and you could use it in a custom TABLE template. However, the CALL DEFINE method to build a dynamic URL can only be used with PROC REPORT. The advantage of the format method is that it's simpler to code (even if you have a LOT of serial numbers, you could generate the format in a program if you really needed to); the advantage of the other method (CALL DEFINE) is that the URL is built dynamically -- without having a user-defined format.&lt;BR /&gt;
  &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data serialnums;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input serial $ val1 val2 state $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
abc123 12  4 WA&lt;BR /&gt;
abc123 15  3 CA&lt;BR /&gt;
abc123 25 10 ND&lt;BR /&gt;
xyz123 10  5 NC&lt;BR /&gt;
xyz123 10  4 MA&lt;BR /&gt;
xyz123  5  2 DE&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                    &lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $fmtser 'xyz123' = 'http://website.com/xyz123'&lt;BR /&gt;
                'abc123' = 'http://website.com/abc123';&lt;BR /&gt;
run;&lt;BR /&gt;
              &lt;BR /&gt;
ods html path='c:\temp' (url=none)&lt;BR /&gt;
         file='linkserial.html' style=sasweb;&lt;BR /&gt;
     &lt;BR /&gt;
proc report data=serialnums nowd&lt;BR /&gt;
     split='#';&lt;BR /&gt;
   title 'Two Ways to Do URL Links';&lt;BR /&gt;
   column serial serial=otherway val1 val2 n;&lt;BR /&gt;
   define serial / group &lt;BR /&gt;
          style(column)={url=$fmtser.};&lt;BR /&gt;
   define otherway / group 'Alternate#Method';&lt;BR /&gt;
   define val1 / sum "Amt#Sold";&lt;BR /&gt;
   define val2 / sum "Amt#Discounted";&lt;BR /&gt;
   define n / 'Number#of States';&lt;BR /&gt;
   compute otherway;&lt;BR /&gt;
     length tmpvar $30;&lt;BR /&gt;
     tmpvar=catt('http://website.com/',serial);&lt;BR /&gt;
     call define(_COL_,'URL',tmpvar);&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
title; &lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
    <pubDate>Wed, 10 Sep 2008 20:32:35 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2008-09-10T20:32:35Z</dc:date>
    <item>
      <title>Inserting additional characters into a column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44924#M5169</link>
      <description>Currently, I have a column that contains the serial number of the row.  I need to recode this column so that it is a weblink.  For example:&lt;BR /&gt;
&lt;BR /&gt;
currently the column contains &lt;I&gt;SERIAL&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
I need to replace &lt;I&gt;SERIAL&lt;/I&gt; with "a href=http://website.com/&lt;I&gt;SERIAL&lt;/I&gt;SERIAL"&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Bill</description>
      <pubDate>Wed, 10 Sep 2008 19:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44924#M5169</guid>
      <dc:creator>BillS</dc:creator>
      <dc:date>2008-09-10T19:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting additional characters into a column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44925#M5170</link>
      <description>Hi:&lt;BR /&gt;
  This is something that is relatively easy to do with PROC REPORT. You have 2 ways to do it. You can either do it in a user-defined format and then use the URL= suboption to build the link. Or, you can use a CALL DEFINE statement with the URL attribute as argument 2 to the CALL DEFINE statement.&lt;BR /&gt;
&lt;BR /&gt;
  These 2 methods take advantage of the fact that ODS knows how to build an anchor tag. So you do not have to code the entire URL &amp;lt;A&amp;gt; tag. ODS does that for you.&lt;BR /&gt;
&lt;BR /&gt;
  Both methods are shown in the program below. (the URL= style attribute method will also work with PROC PRINT and PROC TABULATE and you could use it in a custom TABLE template. However, the CALL DEFINE method to build a dynamic URL can only be used with PROC REPORT. The advantage of the format method is that it's simpler to code (even if you have a LOT of serial numbers, you could generate the format in a program if you really needed to); the advantage of the other method (CALL DEFINE) is that the URL is built dynamically -- without having a user-defined format.&lt;BR /&gt;
  &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data serialnums;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input serial $ val1 val2 state $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
abc123 12  4 WA&lt;BR /&gt;
abc123 15  3 CA&lt;BR /&gt;
abc123 25 10 ND&lt;BR /&gt;
xyz123 10  5 NC&lt;BR /&gt;
xyz123 10  4 MA&lt;BR /&gt;
xyz123  5  2 DE&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                    &lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $fmtser 'xyz123' = 'http://website.com/xyz123'&lt;BR /&gt;
                'abc123' = 'http://website.com/abc123';&lt;BR /&gt;
run;&lt;BR /&gt;
              &lt;BR /&gt;
ods html path='c:\temp' (url=none)&lt;BR /&gt;
         file='linkserial.html' style=sasweb;&lt;BR /&gt;
     &lt;BR /&gt;
proc report data=serialnums nowd&lt;BR /&gt;
     split='#';&lt;BR /&gt;
   title 'Two Ways to Do URL Links';&lt;BR /&gt;
   column serial serial=otherway val1 val2 n;&lt;BR /&gt;
   define serial / group &lt;BR /&gt;
          style(column)={url=$fmtser.};&lt;BR /&gt;
   define otherway / group 'Alternate#Method';&lt;BR /&gt;
   define val1 / sum "Amt#Sold";&lt;BR /&gt;
   define val2 / sum "Amt#Discounted";&lt;BR /&gt;
   define n / 'Number#of States';&lt;BR /&gt;
   compute otherway;&lt;BR /&gt;
     length tmpvar $30;&lt;BR /&gt;
     tmpvar=catt('http://website.com/',serial);&lt;BR /&gt;
     call define(_COL_,'URL',tmpvar);&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
title; &lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 10 Sep 2008 20:32:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44925#M5170</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-09-10T20:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting additional characters into a column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44926#M5171</link>
      <description>My solution:&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input x $20.  ;&lt;BR /&gt;
if substr(x,1,6)='serial' then y='wwwyony///ssa#$%';&lt;BR /&gt;
else y=x;&lt;BR /&gt;
cards;&lt;BR /&gt;
serial &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Hope I understood what you want</description>
      <pubDate>Thu, 11 Sep 2008 07:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44926#M5171</guid>
      <dc:creator>yonib</dc:creator>
      <dc:date>2008-09-11T07:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting additional characters into a column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44927#M5172</link>
      <description>My guess is:&lt;BR /&gt;
&lt;BR /&gt;
data outputTable;&lt;BR /&gt;
length serial $200;&lt;BR /&gt;
set inputTable ;&lt;BR /&gt;
serial=compbl("a href=http://website.com/"||SERIAL||"&amp;gt;"||SERIAL);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Thu, 11 Sep 2008 09:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44927#M5172</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-09-11T09:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting additional characters into a column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44928#M5173</link>
      <description>This solution (putting the entire anchor tag) into an output data set is building a column that contains an anchor tag. The anchor tag will not turn into a link until HTML comes into play somehow -- this points to a report procedure and ODS HTML at a minimum or FILE PRINT ODS and ODS HTML. At the very least, in EG, you would have to run a List Data task on the output table in order to be able to see the links "in action".&lt;BR /&gt;
&lt;BR /&gt;
Also, the URL that you build, must be syntactically correct. An &amp;lt;A&amp;gt; tag is not syntactically correct until the &amp;lt;/A&amp;gt; is also provided. ( I suspect that you had the closing tag in your code, but that it was "disappeared" by the forum text editor.)&lt;BR /&gt;
&lt;BR /&gt;
If you use the SERIALNUMS data from the above example, either of these will produce a detail report table with a hyperlink on every row -- assuming that the anchor tag is already a column in the data. However, if all you want is a hyperlink in the HTML output report, then PROC REPORT can also do that in a CALL DEFINE without needing to build a separate column.&lt;BR /&gt;
&lt;BR /&gt;
EG is doing the equivalent of the ODS HTML "sandwich" for you, so the PROC PRINT on the output table is the equivalent of the List Data task. I highlighted the background of the link to make it stand out from the "regular" SERIAL column.&lt;BR /&gt;
               &lt;BR /&gt;
cynthia&lt;BR /&gt;
               &lt;BR /&gt;
[pre]&lt;BR /&gt;
data serialnums;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input serial $ val1 val2 state $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
abc123 12  4 WA&lt;BR /&gt;
abc123 15  3 CA&lt;BR /&gt;
abc123 25 10 ND&lt;BR /&gt;
xyz123 10  5 NC&lt;BR /&gt;
xyz123 10  4 MA&lt;BR /&gt;
xyz123  5  2 DE&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
           &lt;BR /&gt;
ods html file='c:\temp\showlinks_detail.html' style=sasweb;&lt;BR /&gt;
           &lt;BR /&gt;
proc report data=serialnums nowd&lt;BR /&gt;
     split='#';&lt;BR /&gt;
   title 'Detail Report With URL Links directly from SERIAL value';&lt;BR /&gt;
   column serial val1 val2 state;&lt;BR /&gt;
   define serial / display; &lt;BR /&gt;
   define val1 / sum "Amt#Sold";&lt;BR /&gt;
   define val2 / sum "Amt#Discounted";&lt;BR /&gt;
   define State / 'State #Code';&lt;BR /&gt;
   compute serial;&lt;BR /&gt;
     length tmpvar $30;&lt;BR /&gt;
     tmpvar=catt('http://website.com/',serial);&lt;BR /&gt;
     call define(_COL_,'URL',tmpvar);&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
             &lt;BR /&gt;
title 'With Data Step directly';&lt;BR /&gt;
data outputTable;&lt;BR /&gt;
set serialnums ;&lt;BR /&gt;
length ser_link $200;&lt;BR /&gt;
ser_link=compbl("&amp;lt;a href=http://website.com/"||SERIAL||"&amp;gt;"||SERIAL||'&amp;lt;/a&amp;gt;');&lt;BR /&gt;
file print ods;&lt;BR /&gt;
put _ods_;&lt;BR /&gt;
run;&lt;BR /&gt;
              &lt;BR /&gt;
proc print data=outputTable;&lt;BR /&gt;
  title 'Print on Data set: link contained in new column';&lt;BR /&gt;
  var serial val1 val2 state; &lt;BR /&gt;
  var ser_link / style(data)={background=cxeeeeee};&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
           &lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 11 Sep 2008 20:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Inserting-additional-characters-into-a-column/m-p/44928#M5173</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-09-11T20:40:58Z</dc:date>
    </item>
  </channel>
</rss>

