<?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: Odd behaviour of exist function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803774#M316501</link>
    <description>If you use Data Step, you would get right answer. Macro is a TEXT processed language, therefore there is no need quote around DATA .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt; x=exist("SASHELP.CLASS", "DATA");&lt;BR /&gt; put x=;&lt;BR /&gt;run;</description>
    <pubDate>Thu, 24 Mar 2022 12:15:05 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-03-24T12:15:05Z</dc:date>
    <item>
      <title>Odd behaviour of exist function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803762#M316496</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;why does SAS return a zero, meaning the dataset does not exist, even though it exists!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %PUT  ***** %sysfunc(exist(SASHELP.CLASS , 'ACCESS'));
  
  %PUT  ***** %sysfunc(exist(SASHELP.CLASS, 'CATALOG'));
  
  %PUT  ***** %sysfunc(exist(SASHELP.CLASS, 'VIEW'));
  
  %PUT  ***** %sysfunc(exist(SASHELP.CLASS, 'DATA'));

  %PUT  ***** %sysfunc(exist(SASHELP.CLASS, "DATA"));

  %PUT  ***** %sysfunc(exist(SASHELP.CLASS,       ));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;result in the Log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;19           %PUT  ***** %sysfunc(exist(SASHELP.CLASS , 'ACCESS'));
***** 0
20         
21           %PUT  ***** %sysfunc(exist(SASHELP.CLASS, 'CATALOG'));
***** 0
22         
23           %PUT  ***** %sysfunc(exist(SASHELP.CLASS, 'VIEW'));
***** 0
24         
25           %PUT  ***** %sysfunc(exist(SASHELP.CLASS, 'DATA'));
***** 0
26         
27           %PUT  ***** %sysfunc(exist(SASHELP.CLASS, "DATA"));
***** 0
28         
29           %PUT  ***** %sysfunc(exist(SASHELP.CLASS,       ));
***** 1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p1thpm9d6f5itan1c37zh8uz273z.htm" target="_self"&gt;exist documentation&lt;/A&gt;&amp;nbsp; tells me, that I can use the optional "&lt;EM class="xisDoc-userSuppliedValue"&gt;member-type" argument. By default it is "DATA".&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;However, when explicitly using "DATA" or 'DATA' as the optional member-type argument, the function returns the wrong value, i.e. "0"!&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;Only, when I do not enclose the word DATA in quotes, it returns the correct value:&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %PUT  ***** %sysfunc(exist(SASHELP.CLASS,   DATA    ));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;29           %PUT  ***** %sysfunc(exist(SASHELP.CLASS,   DATA    ));
***** 1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;Am I the only one who gets a littlbe bit confused by this behaviour?&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 11:15:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803762#M316496</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2022-03-24T11:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Odd behaviour of exist function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803766#M316497</link>
      <description>&lt;P&gt;This has nothing to do with the EXIST function. It is a "feature" of %SYSFUNC, where arguments to the function inside %SYSFUNC must not be enclosed in quotes (although if you used the same function without %SYSFUNC inside a data step, quotes are required around character values). This is a global condition (as far as I know) in %SYSFUNC, meaning that ANY function inside of %SYSFUNC should not have quotes around the arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similar example with INTNX, works with no quotes around the arguments, but produces an error with quotes around the arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %let today=%sysfunc(today());
  %put %sysfunc(intnx(month,&amp;amp;today,1,b));
  %put %sysfunc(intnx('month',&amp;amp;today,1,'b'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 11:42:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803766#M316497</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-24T11:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Odd behaviour of exist function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803773#M316500</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114220"&gt;@FK1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is natural behaviour of the SAS macro language. When you write code in macro language there is _only_ one data type: text. Everything in macro language is a text so no "quotes" are needed. Starting with PUT statement, in 4GL you are writing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put "My text to be displayed";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and in macro language you just do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put My text to be displayed;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This behaviour is extending for "%sysfunc-ed" functions arguments too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a bit from documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1o13d7wb2zfcnn19s5ssl2zdxvi.htm#p19u61fg1om5kdn13d3kn1cnl3u7" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1o13d7wb2zfcnn19s5ssl2zdxvi.htm#p19u61fg1om5kdn13d3kn1cnl3u7&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 11:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803773#M316500</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-03-24T11:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Odd behaviour of exist function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803774#M316501</link>
      <description>If you use Data Step, you would get right answer. Macro is a TEXT processed language, therefore there is no need quote around DATA .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt; x=exist("SASHELP.CLASS", "DATA");&lt;BR /&gt; put x=;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 24 Mar 2022 12:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803774#M316501</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-03-24T12:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Odd behaviour of exist function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803779#M316503</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you all for your contributions. Now, I understand the issue!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 12:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Odd-behaviour-of-exist-function/m-p/803779#M316503</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2022-03-24T12:36:26Z</dc:date>
    </item>
  </channel>
</rss>

