<?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: Error when trying to create correlation heat map with spearman in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/291102#M10264</link>
    <description>&lt;P&gt;Did the code work before introducing macro language?&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2016 00:00:48 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-08-12T00:00:48Z</dc:date>
    <item>
      <title>Error when trying to create correlation heat map with spearman</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/291034#M10263</link>
      <description>&lt;P&gt;Hi, I'm trying to create a heat map using spearman correlations, but am getting the following errors when running sgrender:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;java.lang.ArrayIndexOutOfBoundsException: 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;ERROR: Physical file does not exist, /tmp/SAS_work50EB00006B2C_localhost.localdomain/_4D29A1B845FFE4BBCA177128127DE4A.bmp.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;When I try to run the same code calling for pearson, it works perfectly. Does anyone know why this error occurs when trying to generate the map using spearman and not pearson?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Here is the code I am using:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc template;&lt;BR /&gt;define statgraph corrHeatmap;&lt;BR /&gt;dynamic _Title;&lt;BR /&gt;begingraph;&lt;BR /&gt;entrytitle _Title;&lt;BR /&gt;rangeattrmap name='map';&lt;BR /&gt;range -1 - 1 / rangecolormodel=(cxfc8d59 cxffffbf cx91bfdb);&lt;BR /&gt;endrangeattrmap;&lt;BR /&gt;rangeattrvar var=r attrvar=r attrmap='map';&lt;BR /&gt;layout overlay /&lt;BR /&gt;xaxisopts=(display=(line ticks tickvalues))&lt;BR /&gt;yaxisopts=(display=(line ticks tickvalues));&lt;BR /&gt;heatmapparm x = x y = y colorresponse = r / xbinaxis=false ybinaxis=false&lt;BR /&gt;colormodel=THREECOLORRAMP name = "heatmap" display=all;&lt;BR /&gt;continuouslegend "heatmap" /&lt;BR /&gt;orient = vertical location = outside title="Spearman Correlation";&lt;BR /&gt;endlayout;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro prepCorrData(in=,out=);&lt;BR /&gt;proc corr data=&amp;amp;in. spearman nocorr&lt;BR /&gt;outs=work._tmpCorr&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data &amp;amp;out.;&lt;BR /&gt;keep x y r;&lt;BR /&gt;set work._tmpCorr(where=(_TYPE_="CORR"));&lt;BR /&gt;array v{*} _numeric_;&lt;BR /&gt;x = _NAME_;&lt;BR /&gt;do i = dim(v) to 1 by -1;&lt;BR /&gt;y = vname(v(i));&lt;BR /&gt;r = v(i);&lt;BR /&gt;/* creates a diagonally sparse matrix */&lt;BR /&gt;if (i&amp;lt;_n_) then&lt;BR /&gt;r=.;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc datasets lib=work nolist nowarn;&lt;BR /&gt;delete _tmpcorr;&lt;BR /&gt;quit;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%prepCorrData(&lt;BR /&gt;in=work.one, out=one_heat);&lt;BR /&gt;proc sgrender data=one_heat template=corrheatmap;&lt;BR /&gt;dynamic _title="Correlation Matrix at 12 Months";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 18:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/291034#M10263</guid>
      <dc:creator>lnraines</dc:creator>
      <dc:date>2016-08-11T18:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error when trying to create correlation heat map with spearman</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/291102#M10264</link>
      <description>&lt;P&gt;Did the code work before introducing macro language?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 00:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/291102#M10264</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-12T00:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error when trying to create correlation heat map with spearman</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/291236#M10269</link>
      <description>I haven't tried the code without the macro, but it works for pearson with&lt;BR /&gt;the macro. For example, if I change the output in the proc corr statement&lt;BR /&gt;to outp=work._tmpCorr (of course removing nocorr), the heat maps generate&lt;BR /&gt;fine. It's only if I try outs= to call the spearman correlations, that I&lt;BR /&gt;get these errors.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Fri, 12 Aug 2016 12:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/291236#M10269</guid>
      <dc:creator>lnraines</dc:creator>
      <dc:date>2016-08-12T12:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Error when trying to create correlation heat map with spearman</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/292153#M10305</link>
      <description>&lt;P&gt;I have the solution in case anyone has this problem in the future (via: &lt;SPAN class="fn n"&gt;Chris Hemedinger of The SAS Dummy)&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I found the issue. It's a precision issue with the Spearman output, which sometimes can be so close to 1.0 for self-correlations but can actually be just a tiny bit over 1. That value falls outside of the colormap range that is defined in the GTL code. We can work around with the ROUND function in preparing the matrix for plotting.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Change the DATA step in the "prep data" portion to:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="comment-content"&gt;&lt;P&gt;&lt;CODE&gt;data &amp;amp;out.;&lt;BR /&gt;keep x y r;&lt;BR /&gt;set work._tmpCorr(where=(_TYPE_="CORR"));&lt;BR /&gt;array v{*} _numeric_;&lt;BR /&gt;x = _NAME_;&lt;BR /&gt;do i = dim(v) to 1 by -1;&lt;BR /&gt;y = vname(v(i));&lt;BR /&gt;/* Round to account for precision differences */&lt;BR /&gt;r = round( v(i), 0.0000001 );&lt;BR /&gt;/* creates a diagonally sparse matrix */&lt;BR /&gt;if (i&amp;lt;_n_) then&lt;BR /&gt;r=.;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class="comment-reply-link"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 17 Aug 2016 12:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-when-trying-to-create-correlation-heat-map-with-spearman/m-p/292153#M10305</guid>
      <dc:creator>lnraines</dc:creator>
      <dc:date>2016-08-17T12:55:59Z</dc:date>
    </item>
  </channel>
</rss>

