<?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: Conditional logic in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75360#M16230</link>
    <description>Wksht is resolved as Sheet1$.Strangely this is not working:&lt;BR /&gt;
202  proc sql;&lt;BR /&gt;
203   delete from tabnaes where table_name like '%(2)%'  or table_name like '%FEIBA%' or&lt;BR /&gt;
204   table_name like '%NAMES%';&lt;BR /&gt;
NOTE: 3 rows were deleted from WORK.TABNAES.&lt;BR /&gt;
&lt;BR /&gt;
205   select table_name into:wksht from tabnaes;&lt;BR /&gt;
206   quit;&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           0.04 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
207   %put &amp;amp;wksht;&lt;BR /&gt;
Sheet1$&lt;BR /&gt;
&lt;BR /&gt;
208  %macro test;&lt;BR /&gt;
209  proc sql;&lt;BR /&gt;
210   connect to excel (path="&amp;amp;inpt.\BIO RX 2009 08.xls"&lt;BR /&gt;
211                     header=no mixed=yes );&lt;BR /&gt;
212&lt;BR /&gt;
213   create table BioRx as&lt;BR /&gt;
214     select * from connection to excel&lt;BR /&gt;
215     %if %substr(%superQ(wksht),1,1) = %str(%') %then %do;&lt;BR /&gt;
216   (select * from [%sysfunc(dequote(%superQ(wksht)))]);&lt;BR /&gt;
217  %end;&lt;BR /&gt;
218  %else %do;&lt;BR /&gt;
219  (select * from [&amp;amp;wksht]);&lt;BR /&gt;
220  %end&lt;BR /&gt;
221    disconnect from excel;&lt;BR /&gt;
NOTE: Extraneous information on %END statement ignored.&lt;BR /&gt;
222  quit;&lt;BR /&gt;
223  %mend test;&lt;BR /&gt;
224  %test;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Describe: ColumnInfo not available</description>
    <pubDate>Fri, 09 Oct 2009 18:19:35 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2009-10-09T18:19:35Z</dc:date>
    <item>
      <title>Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75358#M16228</link>
      <description>How to put a condition for the second select statement:&lt;BR /&gt;
&lt;BR /&gt;
if the macro wksht has quotes around it then use the select statement :&lt;BR /&gt;
(select * from [%sysfunc(dequote(%superQ(wksht)))]);&lt;BR /&gt;
&lt;BR /&gt;
if the macro wksht doesnt have quotes around it then use the select statement:&lt;BR /&gt;
&lt;BR /&gt;
(select * from [&amp;amp;wksht]);&lt;BR /&gt;
&lt;BR /&gt;
%macro test;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 connect to excel (path="&amp;amp;inpt.\BIO RX 2009 08.xls"&lt;BR /&gt;
                   header=no mixed=yes );&lt;BR /&gt;
&lt;BR /&gt;
 create table BioRx as&lt;BR /&gt;
  select * from connection to excel &lt;BR /&gt;
 (select * from [%sysfunc(dequote(%superQ(wksht)))]);&lt;BR /&gt;
    disconnect from excel;&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend test;&lt;BR /&gt;
%test;</description>
      <pubDate>Fri, 09 Oct 2009 17:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75358#M16228</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-10-09T17:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75359#M16229</link>
      <description>If didn't put together a test environment, so this code hasn't been test:&lt;BR /&gt;
------------------------------&lt;BR /&gt;
%macro test;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
connect to excel (path="&amp;amp;inpt.\BIO RX 2009 08.xls"&lt;BR /&gt;
header=no mixed=yes );&lt;BR /&gt;
&lt;BR /&gt;
create table BioRx as&lt;BR /&gt;
select * from connection to excel &lt;BR /&gt;
  %if %substr(%superQ(wksht),1,1) = %str(%') %then %do;&lt;BR /&gt;
    (select * from [%sysfunc(dequote(%superQ(wksht)))]);&lt;BR /&gt;
  %end;&lt;BR /&gt;
  %else %do;&lt;BR /&gt;
    (select * from [&amp;amp;wksht]);&lt;BR /&gt;
  %end;&lt;BR /&gt;
disconnect from excel;&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend test;&lt;BR /&gt;
%test; &lt;BR /&gt;
--------------------------------------------------&lt;BR /&gt;
Of course in your example, it looks like you could go ahead and use the dequote in either case and not worry about the contitional logic.&lt;BR /&gt;
&lt;BR /&gt;
Curtis

Message was edited by: CurtisMack</description>
      <pubDate>Fri, 09 Oct 2009 18:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75359#M16229</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-09T18:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75360#M16230</link>
      <description>Wksht is resolved as Sheet1$.Strangely this is not working:&lt;BR /&gt;
202  proc sql;&lt;BR /&gt;
203   delete from tabnaes where table_name like '%(2)%'  or table_name like '%FEIBA%' or&lt;BR /&gt;
204   table_name like '%NAMES%';&lt;BR /&gt;
NOTE: 3 rows were deleted from WORK.TABNAES.&lt;BR /&gt;
&lt;BR /&gt;
205   select table_name into:wksht from tabnaes;&lt;BR /&gt;
206   quit;&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           0.04 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
207   %put &amp;amp;wksht;&lt;BR /&gt;
Sheet1$&lt;BR /&gt;
&lt;BR /&gt;
208  %macro test;&lt;BR /&gt;
209  proc sql;&lt;BR /&gt;
210   connect to excel (path="&amp;amp;inpt.\BIO RX 2009 08.xls"&lt;BR /&gt;
211                     header=no mixed=yes );&lt;BR /&gt;
212&lt;BR /&gt;
213   create table BioRx as&lt;BR /&gt;
214     select * from connection to excel&lt;BR /&gt;
215     %if %substr(%superQ(wksht),1,1) = %str(%') %then %do;&lt;BR /&gt;
216   (select * from [%sysfunc(dequote(%superQ(wksht)))]);&lt;BR /&gt;
217  %end;&lt;BR /&gt;
218  %else %do;&lt;BR /&gt;
219  (select * from [&amp;amp;wksht]);&lt;BR /&gt;
220  %end&lt;BR /&gt;
221    disconnect from excel;&lt;BR /&gt;
NOTE: Extraneous information on %END statement ignored.&lt;BR /&gt;
222  quit;&lt;BR /&gt;
223  %mend test;&lt;BR /&gt;
224  %test;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Describe: ColumnInfo not available</description>
      <pubDate>Fri, 09 Oct 2009 18:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75360#M16230</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-10-09T18:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75361#M16231</link>
      <description>You left out the ; at the end of:&lt;BR /&gt;
&lt;BR /&gt;
219 (select * from [&amp;amp;wksht]);&lt;BR /&gt;
220 %end</description>
      <pubDate>Fri, 09 Oct 2009 18:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75361#M16231</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-09T18:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75362#M16232</link>
      <description>I'm steill getting an error:&lt;BR /&gt;
&lt;BR /&gt;
242  %macro test;&lt;BR /&gt;
243  proc sql;&lt;BR /&gt;
244   connect to excel (path="T:\NovoLand\Biopharm Business Analysis SAS Project&lt;BR /&gt;
244! (2009)\N7customers\Convert2SAS\BIO RX 2009 08.xls"&lt;BR /&gt;
245                     header=no mixed=yes );&lt;BR /&gt;
246&lt;BR /&gt;
247   create table BioRx as&lt;BR /&gt;
248     select * from connection to excel&lt;BR /&gt;
249     %if %substr(%superQ(wksht),1,1) = %str(%') %then %do;&lt;BR /&gt;
250   (select * from [%sysfunc(dequote(%superQ(wksht)))]);&lt;BR /&gt;
251  %end;&lt;BR /&gt;
252  %else %do;&lt;BR /&gt;
253  (select * from [&amp;amp;wksht]);&lt;BR /&gt;
254  %end;&lt;BR /&gt;
255    disconnect from excel;&lt;BR /&gt;
256  quit;&lt;BR /&gt;
257  %mend test;&lt;BR /&gt;
258  %test;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Describe: ColumnInfo not available</description>
      <pubDate>Fri, 09 Oct 2009 18:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75362#M16232</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-10-09T18:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75363#M16233</link>
      <description>That error has nothing to do with the macro conditional.  It is coming from the Excel engine.  I created a test environment and the code works for me.</description>
      <pubDate>Fri, 09 Oct 2009 18:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75363#M16233</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-09T18:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75364#M16234</link>
      <description>Thanks Curtis.&lt;BR /&gt;
The same code works for other worksheets.But fails for this one.</description>
      <pubDate>Fri, 09 Oct 2009 18:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75364#M16234</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-10-09T18:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75365#M16235</link>
      <description>Opps, I spoke a little too soon.  My logic was not quite working on the quoted values.  The error you were getting is not related however.  Here is a correction.&lt;BR /&gt;
---------------------------------------------&lt;BR /&gt;
%macro test(wksht);&lt;BR /&gt;
proc sql;&lt;BR /&gt;
connect to excel (path="c:\temp\temp.xls"&lt;BR /&gt;
header=no mixed=yes );&lt;BR /&gt;
&lt;BR /&gt;
create table BioRx as&lt;BR /&gt;
select * from connection to excel &lt;BR /&gt;
  %if %qsysfunc(substr(%superQ(wksht),1,1)) = %str(%') %then %do;&lt;BR /&gt;
    (select * from [%sysfunc(dequote(%superQ(wksht)))]);&lt;BR /&gt;
  %end;&lt;BR /&gt;
  %else %do;&lt;BR /&gt;
    (select * from [&amp;amp;wksht]);&lt;BR /&gt;
  %end;&lt;BR /&gt;
disconnect from excel;&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend test;&lt;BR /&gt;
%test(tmp); &lt;BR /&gt;
%test('tmp');</description>
      <pubDate>Fri, 09 Oct 2009 20:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75365#M16235</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2009-10-09T20:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75366#M16236</link>
      <description>Curtis,&lt;BR /&gt;
 macro wksht recolved to 'Data Template$' (with quotes around it).&lt;BR /&gt;
when i run the following i get an error:&lt;BR /&gt;
&lt;BR /&gt;
%macro test;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 connect to excel (path="&amp;amp;inpt.\Nationwide Childrens Hospital 2009 08.xls"&lt;BR /&gt;
                   header=no mixed=yes );&lt;BR /&gt;
&lt;BR /&gt;
 create table NationwideChildern as&lt;BR /&gt;
   select * from connection to excel &lt;BR /&gt;
   %if %substr(%superQ(wksht),1,1) = %str(%') %then %do;&lt;BR /&gt;
 (select * from [%sysfunc(dequote(%superQ(wksht)))]);&lt;BR /&gt;
%end;&lt;BR /&gt;
%else %do;&lt;BR /&gt;
(select * from [&amp;amp;wksht]);&lt;BR /&gt;
%end;  &lt;BR /&gt;
  disconnect from excel;&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend test;&lt;BR /&gt;
%test;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric  operand is required. The condition was: %substr(%superQ(wksht),1,1) = '&lt;BR /&gt;
ERROR: The macro TEST will stop executing.</description>
      <pubDate>Mon, 12 Oct 2009 14:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic/m-p/75366#M16236</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-10-12T14:15:04Z</dc:date>
    </item>
  </channel>
</rss>

