<?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 select vars with prefix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550952#M153021</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207566"&gt;@markc&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be surprised if somebody like PGstats might come up with something as I don't think Proc sql supports variable lists. This means you would have to query dictionary tables and load the varlist in macro separated by ',' and call in a select clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok that being said you could use keep= dataset option like--&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w;
array t(10)(10*35);
j=57665;
run;

proc sql;
create table want as
select *
from w(keep=t:);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Apr 2019 02:49:31 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-04-15T02:49:31Z</dc:date>
    <item>
      <title>PROC SQL select vars with prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550951#M153020</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I use a PROC SQL to select only&amp;nbsp;variables from a SAS table which start with a prefix?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;create table1 as&lt;/P&gt;&lt;P&gt;select a.prefix:,&lt;/P&gt;&lt;P&gt;from table2 as a;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 02:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550951#M153020</guid>
      <dc:creator>markc</dc:creator>
      <dc:date>2019-04-15T02:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL select vars with prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550952#M153021</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207566"&gt;@markc&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be surprised if somebody like PGstats might come up with something as I don't think Proc sql supports variable lists. This means you would have to query dictionary tables and load the varlist in macro separated by ',' and call in a select clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok that being said you could use keep= dataset option like--&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w;
array t(10)(10*35);
j=57665;
run;

proc sql;
create table want as
select *
from w(keep=t:);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 02:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550952#M153021</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-15T02:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL select vars with prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550953#M153022</link>
      <description>&lt;P&gt;You have to spell out each variable when using SQL.&amp;nbsp; There are ways to get macro language to save you some of the typing, but macro language would have to generate a program that lists each variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, if you switch to a DATA step, the coding is easy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have (keep=prefix: ) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Apr 2019 02:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550953#M153022</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-15T02:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL select vars with prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550954#M153023</link>
      <description>&lt;P&gt;You could use sashelp.vcolumns :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into :cols separated by ","
from sashelp.vcolumn 
where libname="SASHELP" and upcase(memname)="HEART" and
    prxmatch("/^s/i", name) ;
create table subset as
select &amp;amp;cols. 
from sashelp.heart;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Apr 2019 02:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-select-vars-with-prefix/m-p/550954#M153023</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-04-15T02:52:35Z</dc:date>
    </item>
  </channel>
</rss>

