<?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 Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43070#M11231</link>
    <description>unfortunately, the variable list notation [pre]   of proc1 - proc12 [/pre]is not accepted in the where handling of data steps either, but the quick work around goes like (let sql fill a comma-separated list of these variables)[pre]%let table = your.dataset ;&lt;BR /&gt;
%let var_prefix = proc ;&lt;BR /&gt;
%let var_list   = ;&lt;BR /&gt;
proc contents data=&amp;amp;table noprint out=_data_ ; run ;&lt;BR /&gt;
proc sql noprint ;&lt;BR /&gt;
select name into :var_list separated by ', '&lt;BR /&gt;
from &amp;amp;syslast &lt;BR /&gt;
where type = 2 /* strings */&lt;BR /&gt;
and upcase(name) eqt "%upcase(&amp;amp;var_prefix)" &lt;BR /&gt;
;&lt;BR /&gt;
quit ;&lt;BR /&gt;
proc sql ;[/pre]   your query  goes here followed by [pre] where catx( '/', &amp;amp;var_list ) ? 'ABC' )</description>
    <pubDate>Thu, 02 Dec 2010 15:23:55 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2010-12-02T15:23:55Z</dc:date>
    <item>
      <title>proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43067#M11228</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I have 12 character variables named proc1, proc2, proc3, proc4, ..., proc12.&lt;BR /&gt;
&lt;BR /&gt;
I would like to check for a value in all the 12 variables using proc sql.&lt;BR /&gt;
&lt;BR /&gt;
I used this code.&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
&lt;BR /&gt;
  create table temp6 as select proc1-proc12&lt;BR /&gt;
			           from temp3&lt;BR /&gt;
			           where proc1-proc12 eqT 'ABC';&lt;BR /&gt;
quit;       &lt;BR /&gt;
&lt;BR /&gt;
I got this error.&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Expression using subtraction (-) requires numeric types.&lt;BR /&gt;
ERROR: Expression using subtraction (-) requires numeric types.&lt;BR /&gt;
ERROR: Expression using equals (=) has components that are of different data types.&lt;BR /&gt;
&lt;BR /&gt;
SAS assumes the hyphen as a minus sign.&lt;BR /&gt;
&lt;BR /&gt;
I want to take the array route if all else fails.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance,&lt;BR /&gt;
Sandhya.</description>
      <pubDate>Thu, 02 Dec 2010 14:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43067#M11228</guid>
      <dc:creator>Sandhya</dc:creator>
      <dc:date>2010-12-02T14:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43068#M11229</link>
      <description>Sandhya&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; I would like to check for a value in all the 12&lt;BR /&gt;
&amp;gt; variables using proc sql.&lt;BR /&gt;
 &lt;BR /&gt;
&amp;gt; 			           where proc1-proc12 eqT 'ABC';&lt;BR /&gt;
   &lt;BR /&gt;
&lt;BR /&gt;
eqT operator compares only the shorter of the two string lengths&lt;BR /&gt;
 &lt;BR /&gt;
? (i.e. the contains) operator seems more likely to help, like&lt;BR /&gt;
  where catx('/', of proc1 - proc12) ? 'ABC' &lt;BR /&gt;
however, I'm not sure sql tolerates variable lists like "of proc1-proc12"&lt;BR /&gt;
So, use a data step.&lt;BR /&gt;
Can you use a data step for this?&lt;BR /&gt;
If not, why not?&lt;BR /&gt;
 &lt;BR /&gt;
peterC

too eager        &lt;BR /&gt;
Message was edited by: Peter.C</description>
      <pubDate>Thu, 02 Dec 2010 15:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43068#M11229</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-12-02T15:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43069#M11230</link>
      <description>Yes I can use the data steps&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Sandhya.</description>
      <pubDate>Thu, 02 Dec 2010 15:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43069#M11230</guid>
      <dc:creator>Sandhya</dc:creator>
      <dc:date>2010-12-02T15:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43070#M11231</link>
      <description>unfortunately, the variable list notation [pre]   of proc1 - proc12 [/pre]is not accepted in the where handling of data steps either, but the quick work around goes like (let sql fill a comma-separated list of these variables)[pre]%let table = your.dataset ;&lt;BR /&gt;
%let var_prefix = proc ;&lt;BR /&gt;
%let var_list   = ;&lt;BR /&gt;
proc contents data=&amp;amp;table noprint out=_data_ ; run ;&lt;BR /&gt;
proc sql noprint ;&lt;BR /&gt;
select name into :var_list separated by ', '&lt;BR /&gt;
from &amp;amp;syslast &lt;BR /&gt;
where type = 2 /* strings */&lt;BR /&gt;
and upcase(name) eqt "%upcase(&amp;amp;var_prefix)" &lt;BR /&gt;
;&lt;BR /&gt;
quit ;&lt;BR /&gt;
proc sql ;[/pre]   your query  goes here followed by [pre] where catx( '/', &amp;amp;var_list ) ? 'ABC' )</description>
      <pubDate>Thu, 02 Dec 2010 15:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43070#M11231</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-12-02T15:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43071#M11232</link>
      <description>Hi.&lt;BR /&gt;
You nearly get the target!&lt;BR /&gt;
Just to use hard code.&lt;BR /&gt;
Such as&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
&lt;BR /&gt;
create table temp6 as select proc1,proc2,......proc12&lt;BR /&gt;
from temp3&lt;BR /&gt;
where proc1 eq  'ABC'  or   proc2 eq  'ABC'  or  proc3 eq  'ABC' or  proc4 eq  'ABC'  ........;&lt;BR /&gt;
quit;</description>
      <pubDate>Fri, 03 Dec 2010 03:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43071#M11232</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-12-03T03:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43072#M11233</link>
      <description>Thank you for your suggestions.  &lt;BR /&gt;
&lt;BR /&gt;
It was very helpful.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Sandhya.</description>
      <pubDate>Mon, 06 Dec 2010 15:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql/m-p/43072#M11233</guid>
      <dc:creator>Sandhya</dc:creator>
      <dc:date>2010-12-06T15:48:31Z</dc:date>
    </item>
  </channel>
</rss>

