<?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: Variable Exists in SAS work dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750709#M236170</link>
    <description>&lt;P&gt;As Tom mentions, why write something when there are mature / well tested macros on github that do the same thing.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Here's the SASjs/core version (which comes without the licence restrictions):&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasjs/core/blob/main/base/mf_existvar.sas" target="_blank"&gt;https://github.com/sasjs/core/blob/main/base/mf_existvar.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Jun 2021 20:42:17 GMT</pubDate>
    <dc:creator>AllanBowe</dc:creator>
    <dc:date>2021-06-27T20:42:17Z</dc:date>
    <item>
      <title>Variable Exists in SAS work dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750278#M235957</link>
      <description>&lt;P&gt;The following code is not working for me:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let dsid=%sysfunc(open("&amp;amp;col1"));&lt;BR /&gt;%let exist=%sysfunc(varnum(&amp;amp;dsid,foldername));&lt;BR /&gt;%let rc =%sysfunc(close(&amp;amp;dsid));&lt;BR /&gt;%put 'exist = ' &amp;amp;exist;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the log file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MLOGIC(ODSDATA): %LET (variable name is DSID)&lt;BR /&gt;SYMBOLGEN: Macro variable COL1 resolves to TXXB&lt;BR /&gt;MLOGIC(ODSDATA): %LET (variable name is EXIST)&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable DSID resolves to 0&lt;BR /&gt;&lt;STRONG&gt;WARNING: Argument 1 to function VARNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;/STRONG&gt;&lt;BR /&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set to a missing value.&lt;BR /&gt;MLOGIC(ODSDATA): %LET (variable name is RC)&lt;BR /&gt;SYMBOLGEN: Macro variable DSID resolves to 0&lt;BR /&gt;MLOGIC(ODSDATA): %PUT 'exist = ' &amp;amp;exist&lt;BR /&gt;SYMBOLGEN: Macro variable EXIST resolves to .&lt;BR /&gt;'exist = ' .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for any solutions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 19:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750278#M235957</guid>
      <dc:creator>cgsmoak56</dc:creator>
      <dc:date>2021-06-24T19:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Exists in SAS work dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750280#M235959</link>
      <description>&lt;P&gt;Do you really have a dataset whose name is the six character string &lt;FONT face="courier new,courier" size="5"&gt;"TXXB"&lt;/FONT&gt;?&lt;/P&gt;
&lt;P&gt;Do not add quotes in macro code unless you actually want the quotes to be part of the value or code you are generating.&lt;/P&gt;
&lt;P&gt;Try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsid=%sysfunc(open(&amp;amp;col1));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note here is a 22+ year old macro you can use to simplify your program.&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/varexist.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/varexist.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 19:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750280#M235959</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-24T19:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Exists in SAS work dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750311#M235982</link>
      <description>&lt;P&gt;Your actual issue is with :&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SYMBOLGEN: Macro variable DSID resolves to 0&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;That means the data set was not opened so there are no variables to look for.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 19:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750311#M235982</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-24T19:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Exists in SAS work dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750460#M236057</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; Removing the " " worked.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 15:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750460#M236057</guid>
      <dc:creator>cgsmoak56</dc:creator>
      <dc:date>2021-06-25T15:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Exists in SAS work dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750709#M236170</link>
      <description>&lt;P&gt;As Tom mentions, why write something when there are mature / well tested macros on github that do the same thing.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Here's the SASjs/core version (which comes without the licence restrictions):&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasjs/core/blob/main/base/mf_existvar.sas" target="_blank"&gt;https://github.com/sasjs/core/blob/main/base/mf_existvar.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 20:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-Exists-in-SAS-work-dataset/m-p/750709#M236170</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-06-27T20:42:17Z</dc:date>
    </item>
  </channel>
</rss>

