<?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: Alternative to using Proc SQL to summarize data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-using-Proc-SQL-to-summarize-data/m-p/630544#M186672</link>
    <description>&lt;P&gt;Use proc summary&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=your_data nway;
class coverage Component LOB status year quarter;
var amount01-amount76;
output out=want(drop=_:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Mar 2020 00:34:10 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-03-09T00:34:10Z</dc:date>
    <item>
      <title>Alternative to using Proc SQL to summarize data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-using-Proc-SQL-to-summarize-data/m-p/630541#M186670</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to summarize the data using Proc SQL procedure into a table. But I have lot of columns in the table that needs summarizing. The column names that I want to Summarize range from " Amount_01, Amount_02, Amount_03 ..upto Amount_76.&lt;/P&gt;&lt;P&gt;It's kind of a long sql query. I was wondering if this can by shortened using some data step procedure or if we can use some loop in Proc sql. I think loops in proc sql is not allowed but I'm not sure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my query and I have just shortened the number of columns&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;Create table test_qtr as&lt;/P&gt;&lt;P&gt;Select coverage&lt;BR /&gt;,Component&lt;BR /&gt;,LOB&lt;BR /&gt;,status&lt;BR /&gt;,year&lt;BR /&gt;,quarter&lt;BR /&gt;, SUM(AMOUNT_01) AS AMOUNT_01&lt;BR /&gt;, SUM(AMOUNT_02) AS AMOUNT_02&lt;BR /&gt;, SUM(AMOUNT_03) AS AMOUNT_03&lt;BR /&gt;, SUM(AMOUNT_04) AS AMOUNT_04&lt;BR /&gt;, SUM(AMOUNT_05) AS AMOUNT_05&lt;BR /&gt;, SUM(AMOUNT_06) AS AMOUNT_06&lt;BR /&gt;, SUM(AMOUNT_07) AS AMOUNT_07&lt;BR /&gt;, SUM(AMOUNT_08) AS AMOUNT_08&lt;BR /&gt;...................&lt;BR /&gt;..................&lt;BR /&gt;...................&lt;BR /&gt;,sum(Amount_71) as Amount_71&lt;BR /&gt;,sum(Amount_72) as Amount_72&lt;BR /&gt;,sum(Amount_73) as Amount_73&lt;BR /&gt;,sum(Amount_74) as Amount_74&lt;BR /&gt;,sum(Amount_75) as Amount_75&lt;BR /&gt;,sum(Amount_76) as Amount_76&lt;BR /&gt;from Data&lt;/P&gt;&lt;P&gt;Group by&lt;BR /&gt;coverage&lt;BR /&gt;,Component&lt;BR /&gt;,LOB&lt;BR /&gt;,status&lt;BR /&gt;,year&lt;BR /&gt;,quarter&lt;BR /&gt;order by 1,2,3,4,5,6;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 00:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-using-Proc-SQL-to-summarize-data/m-p/630541#M186670</guid>
      <dc:creator>carl01</dc:creator>
      <dc:date>2020-03-09T00:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to using Proc SQL to summarize data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-using-Proc-SQL-to-summarize-data/m-p/630543#M186671</link>
      <description>&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want PROC MEANS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc means data = yourInputData noprint;
Class listOfGroupVariables;
Var amount_01-amount_76;
Output out = want sum = / autoname;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/314447"&gt;@carl01&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to summarize the data using Proc SQL procedure into a table. But I have lot of columns in the table that needs summarizing. The column names that I want to Summarize range from " Amount_01, Amount_02, Amount_03 ..upto Amount_76.&lt;/P&gt;
&lt;P&gt;It's kind of a long sql query. I was wondering if this can by shortened using some data step procedure or if we can use some loop in Proc sql. I think loops in proc sql is not allowed but I'm not sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is my query and I have just shortened the number of columns&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;BR /&gt;Create table test_qtr as&lt;/P&gt;
&lt;P&gt;Select coverage&lt;BR /&gt;,Component&lt;BR /&gt;,LOB&lt;BR /&gt;,status&lt;BR /&gt;,year&lt;BR /&gt;,quarter&lt;BR /&gt;, SUM(AMOUNT_01) AS AMOUNT_01&lt;BR /&gt;, SUM(AMOUNT_02) AS AMOUNT_02&lt;BR /&gt;, SUM(AMOUNT_03) AS AMOUNT_03&lt;BR /&gt;, SUM(AMOUNT_04) AS AMOUNT_04&lt;BR /&gt;, SUM(AMOUNT_05) AS AMOUNT_05&lt;BR /&gt;, SUM(AMOUNT_06) AS AMOUNT_06&lt;BR /&gt;, SUM(AMOUNT_07) AS AMOUNT_07&lt;BR /&gt;, SUM(AMOUNT_08) AS AMOUNT_08&lt;BR /&gt;...................&lt;BR /&gt;..................&lt;BR /&gt;...................&lt;BR /&gt;,sum(Amount_71) as Amount_71&lt;BR /&gt;,sum(Amount_72) as Amount_72&lt;BR /&gt;,sum(Amount_73) as Amount_73&lt;BR /&gt;,sum(Amount_74) as Amount_74&lt;BR /&gt;,sum(Amount_75) as Amount_75&lt;BR /&gt;,sum(Amount_76) as Amount_76&lt;BR /&gt;from Data&lt;/P&gt;
&lt;P&gt;Group by&lt;BR /&gt;coverage&lt;BR /&gt;,Component&lt;BR /&gt;,LOB&lt;BR /&gt;,status&lt;BR /&gt;,year&lt;BR /&gt;,quarter&lt;BR /&gt;order by 1,2,3,4,5,6;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 00:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-using-Proc-SQL-to-summarize-data/m-p/630543#M186671</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-09T00:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to using Proc SQL to summarize data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-using-Proc-SQL-to-summarize-data/m-p/630544#M186672</link>
      <description>&lt;P&gt;Use proc summary&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=your_data nway;
class coverage Component LOB status year quarter;
var amount01-amount76;
output out=want(drop=_:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 00:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-using-Proc-SQL-to-summarize-data/m-p/630544#M186672</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-09T00:34:10Z</dc:date>
    </item>
  </channel>
</rss>

