<?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: Using loop to aggregate variables from different tables in PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481577#M124598</link>
    <description>&lt;P&gt;If it's really like that, the solution is extremely simple:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set zzz:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Jul 2018 16:20:16 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-07-26T16:20:16Z</dc:date>
    <item>
      <title>Using loop to aggregate variables from different tables in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481572#M124596</link>
      <description>&lt;P&gt;My situation is I have several different tables that were produced from a macro function that I now want to bring together into one table. The number of tables (lets call the number i) can vary depending on what is run through the program. Lets say my i tables are ZZZ&amp;amp;i and each one has a column result&amp;amp;i, I want to make one dataset where if ZZZ&amp;amp;i exists then result&amp;amp;i is added as a column. I've tried solving this with a %DO loop in PROC SQL but it doesn't seem to accept my code unless the loop is outside my "CREATE TABLE" statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of a successful output would be tables ZZZ1, ZZZ3, and ZZZ4 exist and one final table is created with variables result1, result3, and result4 each from their respective origins.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481572#M124596</guid>
      <dc:creator>MWicks69420</dc:creator>
      <dc:date>2018-07-26T16:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using loop to aggregate variables from different tables in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481577#M124598</link>
      <description>&lt;P&gt;If it's really like that, the solution is extremely simple:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set zzz:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481577#M124598</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-26T16:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using loop to aggregate variables from different tables in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481579#M124599</link>
      <description>&lt;P&gt;Show us what code you have so far? And show us what your data looks like?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481579#M124599</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-26T16:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using loop to aggregate variables from different tables in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481586#M124601</link>
      <description>&lt;P&gt;You can shortcut list data set names as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use : for prefixes or you can use - as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either option below will work most likely. It depends on you having a naming convention so I usually use something like _results to ensure that no other data sets will be included accidentally.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set zzz: ;
set result: ;

set result1-result4;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 16:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481586#M124601</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-26T16:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using loop to aggregate variables from different tables in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481600#M124604</link>
      <description>Thanks! Only problem is it creates a union rather than a join--stuff is stacked vertically creating lots of NULLs, is there any way around this?</description>
      <pubDate>Thu, 26 Jul 2018 17:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481600#M124604</guid>
      <dc:creator>MWicks69420</dc:creator>
      <dc:date>2018-07-26T17:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using loop to aggregate variables from different tables in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481604#M124606</link>
      <description>&lt;P&gt;EDIT: MERGE ZZZ: ; works splendidly!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 17:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481604#M124606</guid>
      <dc:creator>MWicks69420</dc:creator>
      <dc:date>2018-07-26T17:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using loop to aggregate variables from different tables in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481606#M124607</link>
      <description>&lt;P&gt;That's a merge and I think its the same concept, just MERGE instead of SET. Make sure the variable names are unique in each otherwise you can't use this approach because you'll have to rename the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge class: ;
by linked_variable;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 17:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-loop-to-aggregate-variables-from-different-tables-in-PROC/m-p/481606#M124607</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-26T17:19:37Z</dc:date>
    </item>
  </channel>
</rss>

