<?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: Check existence of the variable... in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145818#M38777</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, from my side I would do:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.vcolumn (where=(libname="SASHELP" and memname="CARS" and name="MAKE")); /* You can modify for your variables/tables */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(' .. '); /* do additional programming, could be a macro call or actual code */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if the column(s) specified exist in the dataset(s) supplied, then the call execute generates the code per record.&amp;nbsp; If it doesn't exist then nothing happens.&amp;nbsp; Avoids the whole macro thing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Oct 2014 15:13:11 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2014-10-28T15:13:11Z</dc:date>
    <item>
      <title>Check existence of the variable...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145817#M38776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I Have a library with around 20 datasets. I want to write a macro in such way that it should check for the existence of the variable and If that variable present. Would need to do further processing. I wrote upto this part…….&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE TABLE TABLIST AS SELECT MEMNAME FROM DICTIONARY.TABLES &lt;/P&gt;&lt;P&gt;WHERE LIBNAME = "xxx" ;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MACRO LOOP;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET DSID=%SYSFUNC(OPEN(TABLIST,I));&lt;/P&gt;&lt;P&gt;%LET NOBS=%SYSFUNC(ATTRN(&amp;amp;DSID,NOBS));&lt;/P&gt;&lt;P&gt;%LET RC=%SYSFUNC(CLOSE(&amp;amp;DSID));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%DO J=1 %TO &amp;amp;NOBS;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;SET TABLIST;&lt;/P&gt;&lt;P&gt;IF _N_=&amp;amp;J THEN DO;&lt;/P&gt;&lt;P&gt;CALL SYMPUT ('DOM', COMPRESS(UPCASE(MEMNAME)));&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: yellow;"&gt;Have to determine which one of these variable exists in the table....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: yellow;"&gt;&amp;amp;dom.term,&amp;amp;dom.testcd,&amp;amp;dom.trt.....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: yellow;"&gt;any one of the above variable will be present...based on the existence of which variable the below code continues as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA &amp;amp;DOM;&lt;/P&gt;&lt;P&gt;SET xxx.&amp;amp;DOM;&lt;/P&gt;&lt;P&gt;WHERE not missing (&amp;amp;dom.term)(&amp;amp;dom.testcd)(&amp;amp;dom.trt);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;%mend loop;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2014 15:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145817#M38776</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2014-10-28T15:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Check existence of the variable...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145818#M38777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, from my side I would do:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.vcolumn (where=(libname="SASHELP" and memname="CARS" and name="MAKE")); /* You can modify for your variables/tables */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(' .. '); /* do additional programming, could be a macro call or actual code */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if the column(s) specified exist in the dataset(s) supplied, then the call execute generates the code per record.&amp;nbsp; If it doesn't exist then nothing happens.&amp;nbsp; Avoids the whole macro thing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2014 15:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145818#M38777</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-28T15:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Check existence of the variable...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145819#M38778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I want to know if a variable exist I use this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set ds;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dsid = open("ds");&lt;/P&gt;&lt;P&gt;&amp;nbsp; if varnum(dsid,"var") eq 0 then call symputx('exist',0); /*if not exist, changed to 0*/&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; else call symputx('exist',1);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2014 15:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145819#M38778</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2014-10-28T15:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Check existence of the variable...</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145820#M38779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with RW9.&lt;/P&gt;&lt;P&gt;You can also find the variable names in any table using DICTIONARY TABLES. You do not need to open the dataset in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CTorres&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2014 17:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Check-existence-of-the-variable/m-p/145820#M38779</guid>
      <dc:creator>CTorres</dc:creator>
      <dc:date>2014-10-28T17:36:51Z</dc:date>
    </item>
  </channel>
</rss>

