<?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 Error: Summary functions nested in this way are not supported in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642365#M191603</link>
    <description>&lt;P&gt;I have a proc sql where I'm trying to sum off of a calculated field like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table x as select
  sum(case  
        when t1.admin_dt &amp;gt;=  t2.fromdate1 then t2.unitcost1 
        when t1.admin_dt &amp;gt;=  t2.fromdate2 then t2.unitcost2 
        else t2.unitcost3 
      end) as price_unit_cost,
  sum(case 
        when calculated price_unit_cost is not null then calculated price_unit_cost * t1.quantity
        else t2.unitcost1 * t1.quantity
      end) as alt_price_unit_cost
  from my_table t1 left join my_table2 t2 on (t1.code=t2.code);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However it gives me the error:&amp;nbsp;&lt;STRONG&gt;ERROR: Summary functions nested in this way are not supported&lt;/STRONG&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Apr 2020 18:37:20 GMT</pubDate>
    <dc:creator>PegaZeus</dc:creator>
    <dc:date>2020-04-23T18:37:20Z</dc:date>
    <item>
      <title>Error: Summary functions nested in this way are not supported</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642365#M191603</link>
      <description>&lt;P&gt;I have a proc sql where I'm trying to sum off of a calculated field like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table x as select
  sum(case  
        when t1.admin_dt &amp;gt;=  t2.fromdate1 then t2.unitcost1 
        when t1.admin_dt &amp;gt;=  t2.fromdate2 then t2.unitcost2 
        else t2.unitcost3 
      end) as price_unit_cost,
  sum(case 
        when calculated price_unit_cost is not null then calculated price_unit_cost * t1.quantity
        else t2.unitcost1 * t1.quantity
      end) as alt_price_unit_cost
  from my_table t1 left join my_table2 t2 on (t1.code=t2.code);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However it gives me the error:&amp;nbsp;&lt;STRONG&gt;ERROR: Summary functions nested in this way are not supported&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642365#M191603</guid>
      <dc:creator>PegaZeus</dc:creator>
      <dc:date>2020-04-23T18:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error: Summary functions nested in this way are not supported</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642369#M191606</link>
      <description>&lt;P&gt;Hard to tell what you are actually trying to do since you do not have any GROUP BY clause.&amp;nbsp; Is PRICE_UNIT_COST going to be just one number?&amp;nbsp;&amp;nbsp;If it is just one number then you need to calculate the&amp;nbsp;price_unit_cost first. either as a separate query.&amp;nbsp; Or in a sub-query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;( sum(case  
        when t1.admin_dt &amp;gt;=  t2.fromdate1 then t2.unitcost1 
        when t1.admin_dt &amp;gt;=  t2.fromdate2 then t2.unitcost2 
        else t2.unitcost3 
      end) as price_unit_cost
  from my_table t1 left join my_table2 t2 on (t1.code=t2.code)
) summary
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then figure out how to join that with your other query.&lt;/P&gt;
&lt;P&gt;Or do you want different numbers for different observations?&amp;nbsp; In that case just remove the SUM() from around the CASE ... END.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642369#M191606</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-23T18:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error: Summary functions nested in this way are not supported</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642384#M191615</link>
      <description>&lt;P&gt;There is actually a group by. I forgot to include. It selects/groups by code_p, patient_id, state. Well the values should be different, summed by each group.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 19:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642384#M191615</guid>
      <dc:creator>PegaZeus</dc:creator>
      <dc:date>2020-04-23T19:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error: Summary functions nested in this way are not supported</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642403#M191627</link>
      <description>&lt;P&gt;Why not :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table x as select
  sum(case  
        when t1.admin_dt &amp;gt;=  t2.fromdate1 then t2.unitcost1 
        when t1.admin_dt &amp;gt;=  t2.fromdate2 then t2.unitcost2 
        else t2.unitcost3 
      end) as price_unit_cost,
  sum(case  
        when t1.admin_dt &amp;gt;=  t2.fromdate1 then t2.unitcost1 * t1.quantity
        when t1.admin_dt &amp;gt;=  t2.fromdate2 then t2.unitcost2 * t1.quantity
        else t2.unitcost3 * t1.quantity
      end) as alt_price_unit_cost
  from my_table t1 left join my_table2 t2 on (t1.code=t2.code)
  group by code_p, patient_id, state;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if &lt;EM&gt;price_unit_cost&lt;/EM&gt; is missing, so will &lt;EM&gt;alt_price_unit_cost&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 21:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Summary-functions-nested-in-this-way-are-not-supported/m-p/642403#M191627</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-23T21:01:56Z</dc:date>
    </item>
  </channel>
</rss>

