<?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; union seems cumbersome in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439495#M69141</link>
    <description>&lt;P&gt;Append is more advantageous because its not expecting any calculations and is a straight 'copy' type task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other approaches allow you to modify the data while inserting/updating/union&amp;nbsp;which can also have it's own advantages.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2018 22:07:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-22T22:07:31Z</dc:date>
    <item>
      <title>proc sql; union seems cumbersome</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439452#M69136</link>
      <description>&lt;P&gt;The code below works fine, the first part groups by date,fico,product, the second part does not group on fico, as I want it to be on the portfolio level, hence the variable 'Portfolio' as fico format=$9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to do this in one step without the union?&amp;nbsp; I'd like to only have one 'from' statement.&amp;nbsp; Pulling from the dataset twice doubles the time it takes to build this and I have many of them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table avg_fico as&lt;BR /&gt;select distinct intnx('month',OPEN_DT,0,'e') as OPEN_DT format=mmddyy10.,fico as fico,product,sum(cbscore_new) as cbscore_num,sum(n_cbscore_new) as cbscore_denom &lt;BR /&gt;from mdj.uloc_format&lt;BR /&gt;group by OPEN_DT,fico,product&lt;BR /&gt;union&lt;BR /&gt;select distinct intnx('month',OPEN_DT,0,'e') as OPEN_DT format=mmddyy10.,'Portfolio' as fico format=$9.,product,sum(cbscore_new) as cbscore_num,sum(n_cbscore_new) as cbscore_denom &amp;nbsp;&lt;BR /&gt;from mdj.uloc_format&lt;BR /&gt;group by OPEN_DT,product&lt;BR /&gt;order by OPEN_DT,fico,product;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 20:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439452#M69136</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2018-02-22T20:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql; union seems cumbersome</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439454#M69137</link>
      <description>&lt;P&gt;PROC MEANS will do multiple levels of calculation at once - since you're using different GROUP BY I'm not sure there's an easy way in SQL to accomplish that. It will also respect variable formats so you can apply a format to the date to ensure the calculation is correct.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 20:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439454#M69137</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-22T20:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql; union seems cumbersome</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439465#M69138</link>
      <description>&lt;P&gt;You can't summarize on two levels at once with SQL, but you can speed things up by asking for &lt;STRONG&gt;union all&lt;/STRONG&gt; instead of &lt;STRONG&gt;union&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 21:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439465#M69138</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-22T21:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql; union seems cumbersome</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439480#M69139</link>
      <description>&lt;P&gt;Not sure if this is a new topic or not but would you recommend this over doing an insert into, append or another data step with a set statement? I have seen most sql developers use the insert into method over the union but due to how&amp;nbsp;SAS compiles am not sure which method is most advantageous.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 21:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439480#M69139</guid>
      <dc:creator>Larrihoover</dc:creator>
      <dc:date>2018-02-22T21:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql; union seems cumbersome</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439495#M69141</link>
      <description>&lt;P&gt;Append is more advantageous because its not expecting any calculations and is a straight 'copy' type task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other approaches allow you to modify the data while inserting/updating/union&amp;nbsp;which can also have it's own advantages.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 22:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439495#M69141</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-22T22:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql; union seems cumbersome</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439581#M69144</link>
      <description>&lt;P&gt;Did you try using a PROC instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=mdj.uloc_format ;
  class open_dt product fico ;
  types open_dt*product*fico open_dt*product ;
  format open_dt yymm7. ;
  var cbscore_new n_csscore_new ;
  output out=avg_fico sum=cbscore_num cbscore_denum ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have to roll you own then summarize at the most detailed level first and then build the higher level summaries from the summary instead of query&amp;nbsp;the raw data again.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 04:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-union-seems-cumbersome/m-p/439581#M69144</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-23T04:01:32Z</dc:date>
    </item>
  </channel>
</rss>

