<?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: creating a html file with target sections in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11180#M3059</link>
    <description>href= is in a data step with html='href="&lt;BR /&gt;
&lt;BR /&gt;
I used proc sort and count+1 to create count. &lt;BR /&gt;
I confirmed that the numbers match the NAME= attribute.&lt;BR /&gt;
&lt;BR /&gt;
Thank you.</description>
    <pubDate>Wed, 28 Apr 2010 17:25:27 GMT</pubDate>
    <dc:creator>gzr2mz39</dc:creator>
    <dc:date>2010-04-28T17:25:27Z</dc:date>
    <item>
      <title>creating a html file with target sections</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11176#M3055</link>
      <description>I have the following data:&lt;BR /&gt;
number  location&lt;BR /&gt;
1        a&lt;BR /&gt;
2        b &lt;BR /&gt;
3        c&lt;BR /&gt;
&lt;BR /&gt;
I would like to create a single html file (test.html) where (for example) test.html/#2 would should:&lt;BR /&gt;
number=2&lt;BR /&gt;
location&lt;BR /&gt;
b&lt;BR /&gt;
&lt;BR /&gt;
Is this possible to do with ods html and &lt;BR /&gt;
proc print;by number;var location;run;&lt;BR /&gt;
Or is there another procedure that I need to use to get these results?&lt;BR /&gt;
Thank you.</description>
      <pubDate>Tue, 27 Apr 2010 23:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11176#M3055</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2010-04-27T23:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: creating a html file with target sections</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11177#M3056</link>
      <description>Hi:&lt;BR /&gt;
  According to the HTML specification, if you have an &amp;lt;A&amp;gt; tag like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&amp;lt;a name="section"&amp;gt;&amp;lt;/a&amp;gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
  &lt;BR /&gt;
Then you are defining a named attribute (in this case, section) and therefore, any reference to&lt;BR /&gt;
&lt;B&gt;filename.html#section &lt;/B&gt; would allow navigation directly to that named section, assuming that the browser was compliant with the HTML spec.&lt;BR /&gt;
&lt;A href="http://www.w3schools.com/html/html_links.asp" target="_blank"&gt;http://www.w3schools.com/html/html_links.asp&lt;/A&gt;&lt;BR /&gt;
[quote from above page]&lt;B&gt;&lt;BR /&gt;
When the name attribute is used, the &amp;lt;a&amp;gt; element defines a named anchor inside a HTML document.&lt;BR /&gt;
          &lt;BR /&gt;
Named anchor are not displayed in any special way. They are invisible to the reader.&lt;BR /&gt;
&lt;/B&gt;[endquote]&lt;BR /&gt;
                   &lt;BR /&gt;
That is the HTML specification. ODS actually inserts name attributes into your ODS HTML output file. The default NAME= attribute starts with 'IDX' and looks like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&amp;lt;a name="IDX"&amp;gt;&amp;lt;/a&amp;gt;  (for the first output table)&lt;BR /&gt;
&amp;lt;a name="IDX1"&amp;gt;&amp;lt;/a&amp;gt;  (for the second output table)&lt;BR /&gt;
&amp;lt;a name="IDX2"&amp;gt;&amp;lt;/a&amp;gt;  (for the third output table)&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                               &lt;BR /&gt;
.... and the numbering continues from there...&lt;BR /&gt;
 &lt;BR /&gt;
If you use the CONTENTS= and FRAME= options, then ODS builds an HTML FRAMESET file that uses the CONTENTS= file and the BODY= file to display inside an HTML frame. Even if you do NOT use CONTENTS= or FRAME=, ODS still inserts the IDX NAME= attributes into the file.&lt;BR /&gt;
                 &lt;BR /&gt;
After you create your HTML file with ODS, you would have to look at the file with NOTEPAD to see the use of the NAME=IDX, NAME=IDX1, etc. For example, if I run this code:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data numloc;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input number location $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 a&lt;BR /&gt;
2 b &lt;BR /&gt;
3 c&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                      &lt;BR /&gt;
ods listing close;&lt;BR /&gt;
** default named section #IDX, #IDX1, #IDX2;&lt;BR /&gt;
ods html file='c:\temp\default.html' style=sasweb;&lt;BR /&gt;
  proc print data=numloc noobs;&lt;BR /&gt;
    by number;&lt;BR /&gt;
    var location;&lt;BR /&gt;
  run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                      &lt;BR /&gt;
Then this is what I would see in NOTEPAD when I examine the HTML file:&lt;BR /&gt;
(some HTML tags deleted to only show relevant sections):&lt;BR /&gt;
[pre]&lt;BR /&gt;
&amp;lt;a name="IDX"&amp;gt;&amp;lt;/a&amp;gt;&lt;BR /&gt;
&amp;lt;div class="c Byline"&amp;gt;number=1&amp;lt;/div&amp;gt;&lt;BR /&gt;
  &lt;BR /&gt;
&amp;lt;th class="l Header" scope="col"&amp;gt;location&amp;lt;/th&amp;gt;&lt;BR /&gt;
&amp;lt;td class="l Data"&amp;gt;a&amp;lt;/td&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
                        &lt;BR /&gt;
&amp;lt;a name="IDX1"&amp;gt;&amp;lt;/a&amp;gt;&lt;BR /&gt;
&amp;lt;div class="c Byline"&amp;gt;number=2&amp;lt;/div&amp;gt;&lt;BR /&gt;
                             &lt;BR /&gt;
&amp;lt;th class="l Header" scope="col"&amp;gt;location&amp;lt;/th&amp;gt;&lt;BR /&gt;
&amp;lt;td class="l Data"&amp;gt;b&amp;lt;/td&amp;gt;&lt;BR /&gt;
                  &lt;BR /&gt;
              &lt;BR /&gt;
&amp;lt;a name="IDX2"&amp;gt;&amp;lt;/a&amp;gt;&lt;BR /&gt;
&amp;lt;div class="c Byline"&amp;gt;number=3&amp;lt;/div&amp;gt;&lt;BR /&gt;
                 &lt;BR /&gt;
&amp;lt;th class="l Header" scope="col"&amp;gt;location&amp;lt;/th&amp;gt;&lt;BR /&gt;
&amp;lt;td class="l Data"&amp;gt;c&amp;lt;/td&amp;gt;&lt;BR /&gt;
 &lt;BR /&gt;
[/pre]&lt;BR /&gt;
       &lt;BR /&gt;
You can alter the string that is used for the NAME= attribute by using the ANCHOR= option in your ODS HTML invocation statement. To alter the string used for NAME=, you would submit an invocation statement something like one of these:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods html file='c:\temp\use_anchor_w.html' anchor='wombat'&lt;BR /&gt;
    style=sasweb;&lt;BR /&gt;
               &lt;BR /&gt;
ods html file='c:\temp\use_anchor.html' anchor='wombat10'&lt;BR /&gt;
    style=sasweb;&lt;BR /&gt;
             &lt;BR /&gt;
ods html file='c:\temp\use_anchor.html' anchor='1'&lt;BR /&gt;
    style=sasweb;&lt;BR /&gt;
  &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
for the above invocations, the following NAME= sections would be created:&lt;BR /&gt;
--ANCHOR='wombat' will make NAME= wombat, wombat1, wombat2&lt;BR /&gt;
--ANCHOR='wombat10' will make NAME= wombat10, wombat11, wombat12&lt;BR /&gt;
--ANCHOR='1' will make NAME= 1, 2, 3&lt;BR /&gt;
                         &lt;BR /&gt;
Of course, now that the NAME= attributes are in the file, you will have to properly construct the HREF= attribute to link directly to that section. Again, looking to the W3C for guidance, the correct way to reference a NAME= section is not with a slash (/) in the HREF= attribute.&lt;BR /&gt;
[quote from w3c site]&lt;B&gt;&lt;BR /&gt;
Example:&lt;BR /&gt;
A named anchor inside an HTML document:&lt;BR /&gt;
       &lt;BR /&gt;
&amp;lt;a name="tips"&amp;gt;Useful Tips Section&amp;lt;/a&amp;gt;  &lt;BR /&gt;
     &lt;BR /&gt;
A link to the Useful Tips Section from the same document: &lt;BR /&gt;
   &lt;BR /&gt;
&amp;lt;a href="#tips"&amp;gt;Jump to the Useful Tips Section&amp;lt;/a&amp;gt;  &lt;BR /&gt;
   &lt;BR /&gt;
A link to the Useful Tips Section from another document:&lt;BR /&gt;
     &lt;BR /&gt;
&amp;lt;a href="http://www.w3schools.com/html_tutorial.htm#tips"&amp;gt;&lt;BR /&gt;
Jump to the Useful Tips Section&amp;lt;/a&amp;gt;  &lt;BR /&gt;
&lt;BR /&gt;
&lt;/B&gt;&lt;BR /&gt;
[endquote]&lt;BR /&gt;
                         &lt;BR /&gt;
Note that none of these examples contain a slash before the # reference to the NAME= section.&lt;BR /&gt;
 &lt;BR /&gt;
The insertion of a NAME= attribute is not related to any particular procedure -- it is part of how ODS constructs an HTML output file. Every output table created by your procedure will get a NAME= section. If your procedure creates 3 tables (which is what happens with the data you describe) then you would get three NAME= attributes. If your procedure of choice only creates 1 output table, then you would only get one NAME= attribute in the HTML file.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 28 Apr 2010 01:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11177#M3056</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-28T01:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: creating a html file with target sections</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11178#M3057</link>
      <description>Great. Thank you for this information.&lt;BR /&gt;
&lt;BR /&gt;
I tried the code out and I got this to work:&lt;BR /&gt;
'href="http://test.com/zipinfo.html#IDX20" target=_blank';&lt;BR /&gt;
&lt;BR /&gt;
However, this doesn't work (the variable count is 1,2,3, etc):&lt;BR /&gt;
href="http://test.com/zipinfo.html#IDX'||trim(left(count))||' target=_blank';&lt;BR /&gt;
&lt;BR /&gt;
Any ideas? Thank you.</description>
      <pubDate>Wed, 28 Apr 2010 16:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11178#M3057</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2010-04-28T16:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: creating a html file with target sections</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11179#M3058</link>
      <description>Hi:&lt;BR /&gt;
I guess I don't understand -WHERE- or -HOW- you're trying to build the HREF= attribute?? &lt;BR /&gt;
  &lt;BR /&gt;
Are you doing this in a DATA step, in PROC PRINT, in PROC REPORT?? In a SAS/GRAPH program??? Inside the HTML file?? &lt;BR /&gt;
  &lt;BR /&gt;
How do you know that COUNT is going to be aligned with the #IDX numbers that SAS automatically assigns when it builds the NAME= attribute for the named sections??&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 28 Apr 2010 17:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11179#M3058</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-28T17:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: creating a html file with target sections</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11180#M3059</link>
      <description>href= is in a data step with html='href="&lt;BR /&gt;
&lt;BR /&gt;
I used proc sort and count+1 to create count. &lt;BR /&gt;
I confirmed that the numbers match the NAME= attribute.&lt;BR /&gt;
&lt;BR /&gt;
Thank you.</description>
      <pubDate>Wed, 28 Apr 2010 17:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11180#M3059</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2010-04-28T17:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: creating a html file with target sections</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11181#M3060</link>
      <description>Hi:&lt;BR /&gt;
  Are you doing something for SAS/GRAPH??  If so, this example may be useful:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/gr08ods2-ex.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/graphref/61884/HTML/default/gr08ods2-ex.htm&lt;/A&gt;&lt;BR /&gt;
  &lt;BR /&gt;
  Modifying the code example a bit using SASHELP.CLASS, I can make the #IDX number use a dataset variable as shown below. &lt;BR /&gt;
&lt;BR /&gt;
Usage-wise, I'm not sure that the "target=_blank" is going to be OK, depending on where/how you plan to use this variable value. Usually, for ODS HTML output, you use the HREFTARGET style attribute to set TARGET=_BLANK:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/24/058.html" target="_blank"&gt;http://support.sas.com/kb/24/058.html&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
If you have questions about creating hyperlinks with ODS and/or with SAS/GRAPH, you might wish to open a track with Tech Support.          &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data testit;&lt;BR /&gt;
  length namedrill $70;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  keep name namedrill;&lt;BR /&gt;
  count+1;&lt;BR /&gt;
  namedrill=catt('HREF=','"','http://test.com/zipinfo.html#IDX',left(put(count,2.0)),' target=_blank','"');&lt;BR /&gt;
run;&lt;BR /&gt;
                           &lt;BR /&gt;
proc print data=testit;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
            &lt;BR /&gt;
Produces:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  Obs                           namedrill                           Name&lt;BR /&gt;
   1    HREF="http://test.com/zipinfo.html#IDX1 target=_blank"     Alfred&lt;BR /&gt;
   2    HREF="http://test.com/zipinfo.html#IDX2 target=_blank"     Alice&lt;BR /&gt;
   3    HREF="http://test.com/zipinfo.html#IDX3 target=_blank"     Barbara&lt;BR /&gt;
   4    HREF="http://test.com/zipinfo.html#IDX4 target=_blank"     Carol&lt;BR /&gt;
   5    HREF="http://test.com/zipinfo.html#IDX5 target=_blank"     Henry&lt;BR /&gt;
   6    HREF="http://test.com/zipinfo.html#IDX6 target=_blank"     James&lt;BR /&gt;
   7    HREF="http://test.com/zipinfo.html#IDX7 target=_blank"     Jane&lt;BR /&gt;
   8    HREF="http://test.com/zipinfo.html#IDX8 target=_blank"     Janet&lt;BR /&gt;
   9    HREF="http://test.com/zipinfo.html#IDX9 target=_blank"     Jeffrey&lt;BR /&gt;
  10    HREF="http://test.com/zipinfo.html#IDX10 target=_blank"    John&lt;BR /&gt;
  11    HREF="http://test.com/zipinfo.html#IDX11 target=_blank"    Joyce&lt;BR /&gt;
  12    HREF="http://test.com/zipinfo.html#IDX12 target=_blank"    Judy&lt;BR /&gt;
  13    HREF="http://test.com/zipinfo.html#IDX13 target=_blank"    Louise&lt;BR /&gt;
  14    HREF="http://test.com/zipinfo.html#IDX14 target=_blank"    Mary&lt;BR /&gt;
  15    HREF="http://test.com/zipinfo.html#IDX15 target=_blank"    Philip&lt;BR /&gt;
  16    HREF="http://test.com/zipinfo.html#IDX16 target=_blank"    Robert&lt;BR /&gt;
  17    HREF="http://test.com/zipinfo.html#IDX17 target=_blank"    Ronald&lt;BR /&gt;
  18    HREF="http://test.com/zipinfo.html#IDX18 target=_blank"    Thomas&lt;BR /&gt;
  19    HREF="http://test.com/zipinfo.html#IDX19 target=_blank"    William&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 28 Apr 2010 19:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/creating-a-html-file-with-target-sections/m-p/11181#M3060</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-28T19:43:13Z</dc:date>
    </item>
  </channel>
</rss>

