<?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 Select-Into-From (Proc SQL) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31094#M7391</link>
    <description>In other versions of SQL (non-SAS) there is an elegant way to create a table of summarized data using&lt;BR /&gt;
&lt;BR /&gt;
SELECT &lt;VARIABLES&gt;&lt;BR /&gt;
INTO &lt;NEW table=""&gt;&lt;BR /&gt;
FROM &lt;OLD table=""&gt;&lt;BR /&gt;
GROUP BY &lt;GROUPING&gt;&lt;BR /&gt;
&lt;BR /&gt;
However the "into" function in Proc SQL seems quite different.  It creates a macro variable rather than a new table.&lt;BR /&gt;
&lt;BR /&gt;
Is there an elegant way to do something like this?  Note that I cannot do a simple Proc Summary, as some variables need to be summed and some need to be maximized.  Thank you in advance.&lt;/GROUPING&gt;&lt;/OLD&gt;&lt;/NEW&gt;&lt;/VARIABLES&gt;</description>
    <pubDate>Tue, 09 Nov 2010 19:32:46 GMT</pubDate>
    <dc:creator>GVeers</dc:creator>
    <dc:date>2010-11-09T19:32:46Z</dc:date>
    <item>
      <title>Select-Into-From (Proc SQL)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31094#M7391</link>
      <description>In other versions of SQL (non-SAS) there is an elegant way to create a table of summarized data using&lt;BR /&gt;
&lt;BR /&gt;
SELECT &lt;VARIABLES&gt;&lt;BR /&gt;
INTO &lt;NEW table=""&gt;&lt;BR /&gt;
FROM &lt;OLD table=""&gt;&lt;BR /&gt;
GROUP BY &lt;GROUPING&gt;&lt;BR /&gt;
&lt;BR /&gt;
However the "into" function in Proc SQL seems quite different.  It creates a macro variable rather than a new table.&lt;BR /&gt;
&lt;BR /&gt;
Is there an elegant way to do something like this?  Note that I cannot do a simple Proc Summary, as some variables need to be summed and some need to be maximized.  Thank you in advance.&lt;/GROUPING&gt;&lt;/OLD&gt;&lt;/NEW&gt;&lt;/VARIABLES&gt;</description>
      <pubDate>Tue, 09 Nov 2010 19:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31094#M7391</guid>
      <dc:creator>GVeers</dc:creator>
      <dc:date>2010-11-09T19:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select-Into-From (Proc SQL)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31095#M7392</link>
      <description>I think you want&lt;BR /&gt;
&lt;BR /&gt;
Proc SQL;&lt;BR /&gt;
&lt;BR /&gt;
CREATE TABLE &lt;NEWTABLE&gt; AS&lt;BR /&gt;
SELECT &lt;VARIABLES&gt;&lt;BR /&gt;
FROM &lt;OLD table=""&gt;&lt;BR /&gt;
GROUP BY &lt;GROUPING&gt;&lt;BR /&gt;
&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Check the documentation for specifics.&lt;/GROUPING&gt;&lt;/OLD&gt;&lt;/VARIABLES&gt;&lt;/NEWTABLE&gt;</description>
      <pubDate>Tue, 09 Nov 2010 19:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31095#M7392</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-11-09T19:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Select-Into-From (Proc SQL)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31096#M7393</link>
      <description>You are my official Savior for the Day.  Thank you thank you.&lt;BR /&gt;
&lt;BR /&gt;
(By the way, I'm sure there's a good reason for it, but it really drives me nuts that there are 50 million versions of the SQL language.)</description>
      <pubDate>Tue, 09 Nov 2010 19:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31096#M7393</guid>
      <dc:creator>GVeers</dc:creator>
      <dc:date>2010-11-09T19:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select-Into-From (Proc SQL)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31097#M7394</link>
      <description>GVeers&lt;BR /&gt;
 &lt;BR /&gt;
&amp;gt; Note that I cannot do a simple Proc Summary, as some&lt;BR /&gt;
&amp;gt; variables need to be summed and some need to be&lt;BR /&gt;
&amp;gt;  maximized.  Thank you in advance.&lt;BR /&gt;
 &lt;BR /&gt;
note that &lt;B&gt;all&lt;/B&gt; you were seeking can be achieved in proc summary. You may not have noticed that most of its documentation is provided under the procedure name "&lt;B&gt;proc means&lt;/B&gt;".&lt;BR /&gt;
For example&lt;BR /&gt;
proc means data= sashelp.class ;  * names the data to analyse ;&lt;BR /&gt;
class sex ;  * grouping variable ;&lt;BR /&gt;
var  age height weight ;  * variables for statistics ;&lt;BR /&gt;
output out= stats /* names your output table */&lt;BR /&gt;
min( age) = youngest&lt;BR /&gt;
max( age)= oldest&lt;BR /&gt;
mean(age)= average_age&lt;BR /&gt;
sum( weight)= total_weight&lt;BR /&gt;
max(height)= tallest ;&lt;BR /&gt;
run ;&lt;BR /&gt;
provides a table with 3 rows: &lt;BR /&gt;
first an overall summary, &lt;BR /&gt;
then a row for each value of the class variables&lt;BR /&gt;
The results table has columns&lt;BR /&gt;
one column for each class variable (just sex in this example)&lt;BR /&gt;
a column (_type_) which indicates the aggregating level &lt;BR /&gt;
a column (_freq_) indicating the number of input rows contributing&lt;BR /&gt;
and a column for each statistic requested.&lt;BR /&gt;
 &lt;BR /&gt;
so just wanted to clarify that, although you may achieve the summarising you need in proc SQL, you might find PROC MEANS more helpful.&lt;BR /&gt;
 &lt;BR /&gt;
good luck&lt;BR /&gt;
peterC</description>
      <pubDate>Wed, 10 Nov 2010 17:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31097#M7394</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-10T17:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select-Into-From (Proc SQL)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31098#M7395</link>
      <description>Pretty cool, Peter.C.  I will keep that in mind next time.</description>
      <pubDate>Wed, 10 Nov 2010 20:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Into-From-Proc-SQL/m-p/31098#M7395</guid>
      <dc:creator>GVeers</dc:creator>
      <dc:date>2010-11-10T20:35:48Z</dc:date>
    </item>
  </channel>
</rss>

