<?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: vartype in macro: ERROR: Required operator not found in expression: in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281377#M57055</link>
    <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do something easy that in another language (e.g. R, Python) would be done typing maximum ten times on a keyboard, just a really short line: check the format of a variable in a macro.&lt;/P&gt;&lt;P&gt;I need a solution to do directly and easily what I need, thanks for your effort inhelping but please answer with a concrete, straighforward and &amp;nbsp;easy solutions (if you have it) proportional to the banality of the problem I am posting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did the following change but there is still something not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if&lt;BR /&gt;/* (vartype(base,&amp;amp;VAR.)='N') */&lt;BR /&gt;&lt;STRONG&gt;%datatyp(&amp;amp;VAR.)=NUMERIC&lt;/STRONG&gt;&lt;BR /&gt;%then %do;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jun 2016 08:41:45 GMT</pubDate>
    <dc:creator>Sir_Highbury</dc:creator>
    <dc:date>2016-06-30T08:41:45Z</dc:date>
    <item>
      <title>vartype in macro: ERROR: Required operator not found in expression:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281363#M57048</link>
      <description>&lt;P&gt;I am runing the following macro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%macro macro_outliers (var=);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(...)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%if (vartype(base,&amp;amp;VAR.)='N') %then %do;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;(...)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%end;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%else %do; %end;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%mend macro_outliers;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I get the following error message:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ERROR: Required operator not found in expression: (vartype(base,&amp;amp;VAR.)='N') &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ERROR: The macro MACRO_OUTLIERS will stop executing.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;since the variable is numeric, the macro should not stop. what is wrong in the check on the variable type?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 07:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281363#M57048</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-06-30T07:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: vartype in macro: ERROR: Required operator not found in expression:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281369#M57051</link>
      <description>&lt;P&gt;You should post more of the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually you need to wrap functions in %sysfunc() within macros&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 08:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281369#M57051</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-30T08:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: vartype in macro: ERROR: Required operator not found in expression:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281374#M57053</link>
      <description>&lt;P&gt;In a macro %if conditition, you can only use&lt;/P&gt;
&lt;P&gt;- literals&lt;/P&gt;
&lt;P&gt;- macro functions&lt;/P&gt;
&lt;P&gt;- macro variables&lt;/P&gt;
&lt;P&gt;To use a data step function, you need to wrap it into a %sysfunc (which is a macro function) call.&lt;/P&gt;
&lt;P&gt;But in your case, I guess you are mistaken about what you can do.&lt;/P&gt;
&lt;P&gt;The vartype function needs a numeric file handle reference to a dataset (coming from the open function) as its first parameter, which will only be present in the context of a &lt;U&gt;running&lt;/U&gt; data step (keep in mind that macro processing always occurs in its own context).&lt;/P&gt;
&lt;P&gt;I suggest that you apply the function in a data _null_ step inside your macro and use call symput to save the result in a macro variable, which can then be used in further macro logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 08:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281374#M57053</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-30T08:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: vartype in macro: ERROR: Required operator not found in expression:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281377#M57055</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do something easy that in another language (e.g. R, Python) would be done typing maximum ten times on a keyboard, just a really short line: check the format of a variable in a macro.&lt;/P&gt;&lt;P&gt;I need a solution to do directly and easily what I need, thanks for your effort inhelping but please answer with a concrete, straighforward and &amp;nbsp;easy solutions (if you have it) proportional to the banality of the problem I am posting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did the following change but there is still something not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if&lt;BR /&gt;/* (vartype(base,&amp;amp;VAR.)='N') */&lt;BR /&gt;&lt;STRONG&gt;%datatyp(&amp;amp;VAR.)=NUMERIC&lt;/STRONG&gt;&lt;BR /&gt;%then %do;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 08:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281377#M57055</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-06-30T08:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: vartype in macro: ERROR: Required operator not found in expression:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281379#M57056</link>
      <description>&lt;P&gt;As Reeza &amp;amp; Kurt said, you need to use %sysfunc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See example 1 in&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000148443.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000148443.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%if (%sysfunc(vartype(&amp;amp;dsid,&amp;amp;i)) = N) %then&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to change it to use the &amp;nbsp;%DATATYP autocall function, need to use the MAUTOSOURCE system option&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 09:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281379#M57056</guid>
      <dc:creator>JohnHoughton</dc:creator>
      <dc:date>2016-06-30T09:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: vartype in macro: ERROR: Required operator not found in expression:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281381#M57057</link>
      <description>&lt;P&gt;The %datatyp autocall macro determines the datatype of a typical macro text expression (always keep in mind that the macro language is first and foremost a text processor!)&lt;/P&gt;
&lt;P&gt;Therefore it is of utmost importance what the contents of &amp;amp;var are.&lt;/P&gt;
&lt;P&gt;If &amp;amp;var contains a variable name, then that &lt;U&gt;name&lt;/U&gt; will be the argument of %datatyp, which then will always return CHAR (SAS names are never pure numbers). If &amp;amp;var contains the name of another macro variable, using &amp;amp;&amp;amp;&amp;amp;var might do the trick.&lt;/P&gt;
&lt;P&gt;If you want to determine the type of a &lt;U&gt;dataset&lt;/U&gt; variable for further use in macro processing, use a data _null_ step.&lt;/P&gt;
&lt;P&gt;Either OPEN the dataset and use the VARTYPE function, or extract the information from SASHELP.VCOLUMN, and then use call symput.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 09:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281381#M57057</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-30T09:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: vartype in macro: ERROR: Required operator not found in expression:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281391#M57061</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 11:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/vartype-in-macro-ERROR-Required-operator-not-found-in-expression/m-p/281391#M57061</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-06-30T11:01:11Z</dc:date>
    </item>
  </channel>
</rss>

