<?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: Proc Corr not excluding rows with zeroes in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Corr-not-excluding-rows-with-zeroes/m-p/384709#M65685</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for that explanation. That's exactly what I did in R. I was hoping SAS had a more automatic way of doing that but I guess not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to graph different variables as part of my EDA to verify some sort of correlation before inputting the dataframe into the algorithm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, thanks for the tip with the By statement!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 01 Aug 2017 18:36:23 GMT</pubDate>
    <dc:creator>tester_777</dc:creator>
    <dc:date>2017-08-01T18:36:23Z</dc:date>
    <item>
      <title>Proc Corr not excluding rows with zeroes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Corr-not-excluding-rows-with-zeroes/m-p/383882#M65618</link>
      <description>&lt;P&gt;Firstly, I just started using SAS two weeks ago. Apologies if this question is basic. Secondly, I am using Enterprise Guide 7.1. Thirdly, I am not getting errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to correlate four independent variables (IV) agaisnt a depedent variable (DV). I know that the independent variables have zeroes and I don't want to include those values when the Pearson correlation coefficients are calculated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dependent variable contains only non negative rational numbers, and so do the independent variables (include zeroes though).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I am running:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ODS GRAPHICS ON;&lt;BR /&gt;&lt;BR /&gt;PROC SORT
	DATA=WORK.mf15126(KEEP= DV IV1 IV2 IV3 IV4 ProductCode)
	OUT=WORK.SORTTempTableSorted
	;
	BY ProductCode;
RUN;

PROC CORR DATA=WORK.SORTTempTableSorted
	PLOTS=SCATTER
	PEARSON
	EXCLNPWGT
	VARDEF=DF
	;
	BY ProductCode;
	WHERE ProductCode eq "blah";
	VAR DV;
	WITH IV1 IV2 IV3 IV4;
RUN;&lt;/PRE&gt;&lt;P&gt;That spits some values. But when I try the same code without EXCLNPWGT, the correlation coefficients are the same. Also, the scatterplot shows me that SAS is considering zeros for the IVs for the plotting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I the went to R, separated all my DV, IV pairs into different dfs, then drop rows with zeroes, then run the corr function, and the results were different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please tell me if I am doing something wrong in the code (or if I am not using the proc corr the way I am supposed to)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 19:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Corr-not-excluding-rows-with-zeroes/m-p/383882#M65618</guid>
      <dc:creator>tester_777</dc:creator>
      <dc:date>2017-07-28T19:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Corr not excluding rows with zeroes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Corr-not-excluding-rows-with-zeroes/m-p/383893#M65619</link>
      <description>&lt;P&gt;To exclude values from calculations you would need to assign a value of missing instead of 0. Or you could exclude rows with zero for the offending variable. If you use this approach you would want to do one variable at a time:&lt;/P&gt;
&lt;PRE&gt;PROC CORR DATA=WORK.SORTTempTableSorted
	PLOTS=SCATTER
	PEARSON
	EXCLNPWGT
	VARDEF=DF
	;
	WHERE ProductCode eq "blah" and IV1&amp;gt;0;
	VAR DV;
	WITH IV1 ;
RUN;&lt;/PRE&gt;
&lt;P&gt;If you exclude on two variables you would likely remove valid values for one or the other for Corr calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if you have a Where ProductCode = 'blah' then the BY ProductCode is meaningless. By really is more useful with 2 or more levels fo the BY variable (especially in procs).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without seeing actual data, actual output and desired output it is hard to say what else may be going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Likely to work an example by hand you don't want to work with may rows of data and may only want one of the IV variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 19:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Corr-not-excluding-rows-with-zeroes/m-p/383893#M65619</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-28T19:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Corr not excluding rows with zeroes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Corr-not-excluding-rows-with-zeroes/m-p/384709#M65685</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for that explanation. That's exactly what I did in R. I was hoping SAS had a more automatic way of doing that but I guess not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to graph different variables as part of my EDA to verify some sort of correlation before inputting the dataframe into the algorithm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, thanks for the tip with the By statement!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 18:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Corr-not-excluding-rows-with-zeroes/m-p/384709#M65685</guid>
      <dc:creator>tester_777</dc:creator>
      <dc:date>2017-08-01T18:36:23Z</dc:date>
    </item>
  </channel>
</rss>

