<?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: Trying to create a table to show a summary in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817182#M322548</link>
    <description>its the same. the only thing I changed was adding the calculated.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;24         proc sql;&lt;BR /&gt;25         create table clms_bydrug&lt;BR /&gt;26         as select cptdescription as drug,&lt;BR /&gt;27         		  cost_sum,&lt;BR /&gt;28         		  count(rollupeventid) as claimct,&lt;BR /&gt;29         		  cost_sum/claimct as avgperclm&lt;BR /&gt;30         from claims&lt;BR /&gt;31         order by drug, cost_sum, calculated claimct, avgperclm;&lt;BR /&gt;ERROR: The following columns were not found in the contributing tables: claimct.</description>
    <pubDate>Wed, 08 Jun 2022 17:33:42 GMT</pubDate>
    <dc:creator>bhca60</dc:creator>
    <dc:date>2022-06-08T17:33:42Z</dc:date>
    <item>
      <title>Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817161#M322542</link>
      <description>&lt;P&gt;I'm trying to create a table where it's listed by cpt&amp;nbsp; (renamed as drug).; then the total cost and total claim count per cpt or drug and the average per claim. How would I do this? Right now I am getting an error:&lt;/P&gt;
&lt;P&gt;This is the claims pull:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table claims
as select 
distinct(memberNo) as memberNo_dist,
planPayer,
rollupeventid,
cpt,
cptdescription,
icd,
icdDescription,
sum(cost) as cost_sum,
eventDate,
providerNPI,
providerName,
providerSpecialty
from table
where providerSpecialty = 'Dermatology'
and eventDate between "2020-12-01" and "2021-12-31"
and claimatRisk=1
and planPayer not in ('C')  
and cpt like ('J%')
group by memberNo_dist, eventDate; 
quit;

/*create a table to show data by drug or cpt code*/

proc sql;
create table clms_bydrug 
as select cptdescription as drug,
		  cost_sum,
		  count(rollupeventid) as claimct,
		  cost_sum/claimct as avgperclm
from claims
order by drug, cost_sum, claimct, avgperclm;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but I get this error:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;23         
24         proc sql;
25         create table clms_bydrug
26         as select cptdescription as drug,
27         		  cost_sum,
28         		  count(rollupeventid) as claimct,
29         		  cost_sum/clmct as avgperclm
30         from claims
31         order by drug, cost_sum, claimct, avgperclm;
ERROR: The following columns were not found in the contributing tables: claimct.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 17:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817161#M322542</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-08T17:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817164#M322544</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order by drug, cost_sum, calculated claimct, avgperclm;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 17:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817164#M322544</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-08T17:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817177#M322546</link>
      <description>31         order by drug, cost_sum, calculated claimct, avgperclm;&lt;BR /&gt;ERROR: The following columns were not found in the contributing tables: claimct.</description>
      <pubDate>Wed, 08 Jun 2022 17:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817177#M322546</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-08T17:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817180#M322547</link>
      <description>&lt;P&gt;Show us the &lt;FONT color="#FF0000"&gt;ENTIRE&lt;/FONT&gt; log for this PROC SQL&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 17:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817180#M322547</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-08T17:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817182#M322548</link>
      <description>its the same. the only thing I changed was adding the calculated.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;24         proc sql;&lt;BR /&gt;25         create table clms_bydrug&lt;BR /&gt;26         as select cptdescription as drug,&lt;BR /&gt;27         		  cost_sum,&lt;BR /&gt;28         		  count(rollupeventid) as claimct,&lt;BR /&gt;29         		  cost_sum/claimct as avgperclm&lt;BR /&gt;30         from claims&lt;BR /&gt;31         order by drug, cost_sum, calculated claimct, avgperclm;&lt;BR /&gt;ERROR: The following columns were not found in the contributing tables: claimct.</description>
      <pubDate>Wed, 08 Jun 2022 17:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817182#M322548</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-08T17:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817183#M322549</link>
      <description>&lt;P&gt;Do you need a GROUP BY in that last query?&lt;/P&gt;
&lt;P&gt;You may need a couple more calculated as well....or just reference by column number which is easier &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table clms_bydrug
 as select cptdescription as drug,
cost_sum,
 count(rollupeventid) as claimct,
 cost_sum/claimct as avgperclm
 from claims
group by calculated drug
 order by 1, 2, 3, 4;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 17:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817183#M322549</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-08T17:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817187#M322551</link>
      <description>&lt;P&gt;This is what I'm getting now:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
23         proc sql;
24         create table clms_bydrug
25         as select cptdescription as drug,
26         		  cost_sum,
27         		  count(rollupeventid) as claimct,
28         		  cost_sum/claimct as avgperclm
29         from claims
30         group by calculated drug
31         order by cost_sum, calculated claimct, avgperclm;
ERROR: The following columns were not found in the contributing tables: claimct.
ERROR: The following columns were not found as CALCULATED references in the immediate query: drug.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
32         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 17:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817187#M322551</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-08T17:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817188#M322552</link>
      <description>&lt;P&gt;Try the updated code&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 17:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817188#M322552</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-08T17:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817189#M322553</link>
      <description>&lt;P&gt;CALCULATED is used before variables that are calculated in this SQL; you don't use it before the names of variables that are in the input table(s). Also, I don't think you can use CALCULATED in GROUP BY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table clms_bydrug
        as select cptdescription as drug,
        cost_sum,
        count(rollupeventid) as claimct,
        cost_sum/calculated claimct as avgperclm
        from claims
        group by cptdescription 
        order by cost_sum, calculated claimct, calculated avgperclm;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 18:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817189#M322553</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-08T18:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create a table to show a summary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817195#M322558</link>
      <description>&lt;P&gt;This worked! It gave me the summary I needed. Thank you!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
23         proc sql;
24         create table clms_bydrug
25         as select distinct(cptdescription) as drug,
26         		  sum(cost_sum) as total,
27         		  count(rollupeventid) as claimct,
28         		  calculated total/calculated claimct as avgperclm
29         from claims
30         group by drug
31         order by calculated total, calculated claimct, calculated avgperclm;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 18:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-a-table-to-show-a-summary/m-p/817195#M322558</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-08T18:17:32Z</dc:date>
    </item>
  </channel>
</rss>

