<?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: shorter way to combine rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767854#M243481</link>
    <description>&lt;P&gt;SQL is very wordy, so it's not&amp;nbsp;good for the goal here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL would use the UNION operator&lt;/P&gt;
&lt;P&gt;Look at the variations on:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table HAVE as
  select .. from TABLE1
&lt;EM&gt;    &amp;lt;some form of union&amp;gt;
&lt;/EM&gt;  select .. from TABLE2
&lt;EM&gt;    &amp;lt;some form of union&amp;gt;&lt;/EM&gt;
  select .. from TABLE3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Sep 2021 09:00:29 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-09-15T09:00:29Z</dc:date>
    <item>
      <title>shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767637#M243399</link>
      <description>&lt;P&gt;Hey forum,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ive 8 tables with the same columns and only 1 row. I want to combine all the rows into one table. For doing that Im using the following steps...Its working. But: It feels like a dirty method. Is there a better (shorter) way to reach the aim? &lt;STRONG&gt;Thank you!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
insert into c5 
select * from c4;
quit;

proc sql;
insert into c6
select * from c5;
quit;

proc sql;
insert into c7 
select * from c6;
quit;

proc sql;
insert into c8 
select * from c7;
quit;

proc sql;
insert into c9
select * from c8;
quit;

proc sql;
insert into c10 
select * from c9;
quit;

proc sql;
insert into c11 
select * from c10;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Sep 2021 09:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767637#M243399</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2021-09-14T09:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767648#M243403</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/388612"&gt;@Konkordanz&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the SET statement with a dataset list in a DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set c4-c11;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Sep 2021 10:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767648#M243403</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-09-14T10:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767685#M243426</link>
      <description>Use the set operator union in proc sql or concatenation in data step</description>
      <pubDate>Tue, 14 Sep 2021 12:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767685#M243426</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-09-14T12:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767752#M243441</link>
      <description>Faster run time or faster coding? &lt;BR /&gt;&lt;BR /&gt;For faster coding, you've seen the solutions provided already. For faster run time use PROC APPEND.&lt;BR /&gt;&lt;BR /&gt;proc append base=c4 data=c5; run;&lt;BR /&gt;proc append base=c4 data=c6; run;&lt;BR /&gt;proc append base=c4 data=c7; run;&lt;BR /&gt;....</description>
      <pubDate>Tue, 14 Sep 2021 15:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767752#M243441</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-14T15:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767838#M243471</link>
      <description>A solution with sql would be great...but I dont get your point, sry. Can you please show it to me as code?</description>
      <pubDate>Wed, 15 Sep 2021 06:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767838#M243471</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2021-09-15T06:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767839#M243472</link>
      <description>Thank you! This easy way works! Cause Im learning SAS and SQL im looking also for a solution in SQL...do you have one?</description>
      <pubDate>Wed, 15 Sep 2021 06:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767839#M243472</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2021-09-15T06:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767840#M243473</link>
      <description>Faster coding &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; ... Im leanring SAS and SQL and Im always interested in finding shorter ways for my coding issues.</description>
      <pubDate>Wed, 15 Sep 2021 06:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767840#M243473</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2021-09-15T06:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767841#M243474</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/388612"&gt;@Konkordanz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Faster coding &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; ... Im leanring SAS and SQL and Im always interested in finding shorter ways for my coding issues.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then forget SQL. SQL needs a LOT more code for the UNIONs, the data step is the way to go.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 06:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767841#M243474</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-15T06:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767850#M243479</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/388612"&gt;@Konkordanz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you! This easy way works! Cause Im learning SAS and SQL im looking also for a solution in SQL...do you have one?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you have the names of the datasets to be combined in a dataset like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsnames;
length dsn $3;
do _n_=4 to 11;
  dsn=cat('c',_n_);
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then you can do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select * into :allds separated by ' union all select * from ' from dsnames;
create table want as select * from &amp;amp;allds;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, as&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_blank" rel="noopener"&gt;KurtBremser&lt;/A&gt;&amp;nbsp;said, the DATA step syntax is much shorter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If no dataset like DSNAMES exists, you can retrieve the dataset names from DICTIONARY.TABLES, but this will require even more PROC SQL code.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 08:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767850#M243479</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-09-15T08:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: shorter way to combine rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767854#M243481</link>
      <description>&lt;P&gt;SQL is very wordy, so it's not&amp;nbsp;good for the goal here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL would use the UNION operator&lt;/P&gt;
&lt;P&gt;Look at the variations on:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table HAVE as
  select .. from TABLE1
&lt;EM&gt;    &amp;lt;some form of union&amp;gt;
&lt;/EM&gt;  select .. from TABLE2
&lt;EM&gt;    &amp;lt;some form of union&amp;gt;&lt;/EM&gt;
  select .. from TABLE3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 09:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/shorter-way-to-combine-rows/m-p/767854#M243481</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-09-15T09:00:29Z</dc:date>
    </item>
  </channel>
</rss>

