<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL/m-p/602464#M174446</link>
    <description>Hi:&lt;BR /&gt;  When &amp;amp;K is 1, you create WORK.FINAL from ALLA_KLMEAN1. But then, when &amp;amp;K is 2, you OVERWRITE or REPLACE WORK.FINAL with the results of the the second PROC SQL. You have to change your approach to get both results into the same dataset. I would probably use PROC APPEND or a DATA step.&lt;BR /&gt;&lt;BR /&gt;Cynthia</description>
    <pubDate>Thu, 07 Nov 2019 16:10:14 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2019-11-07T16:10:14Z</dc:date>
    <item>
      <title>Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL/m-p/602462#M174445</link>
      <description>&lt;P&gt;I have the following code within a macro which goes from 1 to 2.&amp;nbsp; Example data for ALL_KLMEAN1 and ALL_KLMEAN2 is included with the code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ALLA_KLMEAN&amp;amp;K;
SET nsum&amp;amp;K;
BY NREP;
IF uclm =&amp;gt; 0.79 THEN ANSWER1=1;
IF uclm LT 0.79 THEN ANSWER1=0;
RUN;

option spool;
proc sql number;
CREATE TABLE FINAL AS 
select UCLM, ANSWER1 ,NREP
from ALLA_KLMEAN&amp;amp;K;
QUIT;

Data:                        nrep                  lclm            uclm       Answer1

ALLA_KLMEAN1        1                   -0.003           0.044         0
ALLA_KLMEAN2        2                    -0.004          0.049         0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After the macro is run the table final only contains the results from ALL_KLMEAN2..&amp;nbsp; I want the final table to contain ALL_KLMEAN2&lt;/P&gt;
&lt;P&gt;and ALL_KLMEAN1 results so it would look like this:&lt;/P&gt;
&lt;P&gt;nrep&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uclm&amp;nbsp;&amp;nbsp;&amp;nbsp; answer1&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.044&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.049&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 16:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL/m-p/602462#M174445</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2019-11-07T16:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL/m-p/602464#M174446</link>
      <description>Hi:&lt;BR /&gt;  When &amp;amp;K is 1, you create WORK.FINAL from ALLA_KLMEAN1. But then, when &amp;amp;K is 2, you OVERWRITE or REPLACE WORK.FINAL with the results of the the second PROC SQL. You have to change your approach to get both results into the same dataset. I would probably use PROC APPEND or a DATA step.&lt;BR /&gt;&lt;BR /&gt;Cynthia</description>
      <pubDate>Thu, 07 Nov 2019 16:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL/m-p/602464#M174446</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-11-07T16:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL/m-p/602465#M174447</link>
      <description>Well you create the final table each time from the most recent run so that is correct. Append the results to a table at the end if you want to keep it instead of using PROC SQL. &lt;BR /&gt;&lt;BR /&gt;proc append base=final data=alla_klmean&amp;amp;k;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Note that you don't need the k in the data set names from what you've shown, it doesn't help anything if you're just stacking your tables.</description>
      <pubDate>Thu, 07 Nov 2019 16:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL/m-p/602465#M174447</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-07T16:11:37Z</dc:date>
    </item>
  </channel>
</rss>

