<?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 SQL: sum of distinct values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70147#M20189</link>
    <description>Hi Simone.&lt;BR /&gt;
Maybe a subquery would help :&lt;BR /&gt;
[pre]PROC SQL ;&lt;BR /&gt;
SELECT SUM(x) FROM (&lt;BR /&gt;
  SELECT DISTINCT id, x FROM myData&lt;BR /&gt;
                   );&lt;BR /&gt;
QUIT ;[/pre]&lt;BR /&gt;
This is very similar to executing a PROC SORT with the NODUPRECS option prior to summing.&lt;BR /&gt;
Hope this helps.&lt;BR /&gt;
Olivier

Message was edited by: Olivier</description>
    <pubDate>Tue, 08 Feb 2011 11:43:12 GMT</pubDate>
    <dc:creator>Olivier</dc:creator>
    <dc:date>2011-02-08T11:43:12Z</dc:date>
    <item>
      <title>Proc SQL: sum of distinct values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70144#M20186</link>
      <description>Hello,&lt;BR /&gt;
with Proc SQL is possible to have the SUM of distinct values of a specific variable. I need an option in this Proc that sum values of a variable referring to different values of another variable. Another way could be the proc sort nodupkey and then the proc freq.&lt;BR /&gt;
&lt;BR /&gt;
Thank you&lt;BR /&gt;
&lt;BR /&gt;
Simone</description>
      <pubDate>Tue, 08 Feb 2011 10:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70144#M20186</guid>
      <dc:creator>HDSimo</dc:creator>
      <dc:date>2011-02-08T10:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL: sum of distinct values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70145#M20187</link>
      <description>when selecting the set of distinct values, or when using the nodupkeys option of proc sort, how do you decide which row to keep or which rows to drop? &lt;BR /&gt;
 &lt;BR /&gt;
I would be concerned that neither method defines which of "the top equal salesmen" (for example) would be chosen to be included on the input to your final summary.</description>
      <pubDate>Tue, 08 Feb 2011 11:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70145#M20187</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-02-08T11:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL: sum of distinct values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70146#M20188</link>
      <description>Hi Peter,&lt;BR /&gt;
each row that i drop has the same values of the row that I keep. Let me show you a situation similar to my database: &lt;BR /&gt;
variable ID identify a person&lt;BR /&gt;
variable X specify a weight&lt;BR /&gt;
&lt;BR /&gt;
In the database there are a lot of duplicated record, It's not important wich rows i've deleted. I need to calculate the sum of x but i can't use X as distinct values option because identical values of X are linked to different ID.&lt;BR /&gt;
&lt;BR /&gt;
Thank you&lt;BR /&gt;
&lt;BR /&gt;
Simone</description>
      <pubDate>Tue, 08 Feb 2011 11:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70146#M20188</guid>
      <dc:creator>HDSimo</dc:creator>
      <dc:date>2011-02-08T11:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL: sum of distinct values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70147#M20189</link>
      <description>Hi Simone.&lt;BR /&gt;
Maybe a subquery would help :&lt;BR /&gt;
[pre]PROC SQL ;&lt;BR /&gt;
SELECT SUM(x) FROM (&lt;BR /&gt;
  SELECT DISTINCT id, x FROM myData&lt;BR /&gt;
                   );&lt;BR /&gt;
QUIT ;[/pre]&lt;BR /&gt;
This is very similar to executing a PROC SORT with the NODUPRECS option prior to summing.&lt;BR /&gt;
Hope this helps.&lt;BR /&gt;
Olivier

Message was edited by: Olivier</description>
      <pubDate>Tue, 08 Feb 2011 11:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70147#M20189</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2011-02-08T11:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL: sum of distinct values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70148#M20190</link>
      <description>mmm... simple!&lt;BR /&gt;
Thank you very much Olivier!&lt;BR /&gt;
&lt;BR /&gt;
Simone</description>
      <pubDate>Tue, 08 Feb 2011 11:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-sum-of-distinct-values/m-p/70148#M20190</guid>
      <dc:creator>HDSimo</dc:creator>
      <dc:date>2011-02-08T11:47:09Z</dc:date>
    </item>
  </channel>
</rss>

