<?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 Adding all rows with a prefix to proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-all-rows-with-a-prefix-to-proc-sql/m-p/683343#M206958</link>
    <description>&lt;P&gt;I have a set of data that I transposed so that now all instances of results are in columns result_1, result_2, etc.&amp;nbsp; Now I need to do additional steps which include PROC SQL and I'm looking for a way to say *add all columns that start with result_*&amp;nbsp; The goal is to automate this program but I won't know how many instances of "result_" their will be for any given time period, as far as I'm aware their is no maximum.&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE test AS&lt;BR /&gt;SELECT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;T1.NAME,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;T1.DATE,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;T2.(ALL COLUMNS THAT START WITH RESULT)&lt;BR /&gt;FROM&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;LIST1 AS T1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;INNER JOIN LIST2 AS T2&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ON T1.UID = T2.UID;&lt;BR /&gt;QUIT;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Sep 2020 19:46:40 GMT</pubDate>
    <dc:creator>JenniferColeDH</dc:creator>
    <dc:date>2020-09-11T19:46:40Z</dc:date>
    <item>
      <title>Adding all rows with a prefix to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-all-rows-with-a-prefix-to-proc-sql/m-p/683343#M206958</link>
      <description>&lt;P&gt;I have a set of data that I transposed so that now all instances of results are in columns result_1, result_2, etc.&amp;nbsp; Now I need to do additional steps which include PROC SQL and I'm looking for a way to say *add all columns that start with result_*&amp;nbsp; The goal is to automate this program but I won't know how many instances of "result_" their will be for any given time period, as far as I'm aware their is no maximum.&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE test AS&lt;BR /&gt;SELECT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;T1.NAME,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;T1.DATE,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;T2.(ALL COLUMNS THAT START WITH RESULT)&lt;BR /&gt;FROM&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;LIST1 AS T1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;INNER JOIN LIST2 AS T2&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ON T1.UID = T2.UID;&lt;BR /&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2020 19:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-all-rows-with-a-prefix-to-proc-sql/m-p/683343#M206958</guid>
      <dc:creator>JenniferColeDH</dc:creator>
      <dc:date>2020-09-11T19:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Adding all rows with a prefix to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-all-rows-with-a-prefix-to-proc-sql/m-p/683352#M206962</link>
      <description>&lt;P&gt;This is one of the limitations of SQL; you can only address columns specifically with their full name.&lt;/P&gt;
&lt;P&gt;Make your selections with a WHERE condition before you transpose, if you need to do that (transpose) at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BIG HINT: long datasets are always better to work with than wide datasets. Write that 10.000 times, or until the message has sunk in.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2020 20:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-all-rows-with-a-prefix-to-proc-sql/m-p/683352#M206962</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-11T20:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding all rows with a prefix to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-all-rows-with-a-prefix-to-proc-sql/m-p/683369#M206972</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284559"&gt;@JenniferColeDH&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In some cases, including the example you've shown, KEEP= and DROP=&amp;nbsp;&lt;EM&gt;dataset options&lt;/EM&gt;&amp;nbsp;(where name prefix lists are allowed) in conjunction with the asterisk notation can overcome that limitation of (PROC) SQL:&lt;/P&gt;
&lt;PRE&gt;PROC SQL;
CREATE TABLE test&lt;FONT size="3"&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;(drop=uid)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt; AS
SELECT
     T1.NAME,
     T1.DATE,
     T2.&lt;FONT size="3" color="#3366FF"&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;&lt;/FONT&gt;
FROM
     LIST1 AS T1
     INNER JOIN LIST2&lt;FONT size="3"&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;(keep=uid result:)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt; AS T2
          ON T1.UID = T2.UID;
QUIT;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Sep 2020 22:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-all-rows-with-a-prefix-to-proc-sql/m-p/683369#M206972</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-09-11T22:09:36Z</dc:date>
    </item>
  </channel>
</rss>

