<?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: Macro stored as character but evaluated as numeric? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617839#M19141</link>
    <description>&lt;P&gt;The same way that this where clause works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where age&amp;gt;30&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro PRE-processor just passes the generated text over to SAS to interpret. SAS will interpret the text the same way it would have interpreted the same text given to it directly from the program file.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jan 2020 17:45:48 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-01-16T17:45:48Z</dc:date>
    <item>
      <title>Macro stored as character but evaluated as numeric?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617830#M19138</link>
      <description>&lt;P&gt;The following code stores the number 30 into macro variable x, but it stores it as a character value, correct?&lt;/P&gt;&lt;P&gt;Given that, how does the following where clause work? If age is stored as numeric and the macro variable x as character, the where clause is conditioning on numeric variable greater than character variable. Why does this work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let x=30;
proc sql;
select *
from table
where age&amp;gt;&amp;amp;x;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 17:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617830#M19138</guid>
      <dc:creator>jdsdog10</dc:creator>
      <dc:date>2020-01-16T17:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro stored as character but evaluated as numeric?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617834#M19139</link>
      <description>It's better to think of it as text. All macro's do is generate SAS code that must be valid. The code above is valid. &lt;BR /&gt;&lt;BR /&gt;Macro variables should be considered TEXT not Character/Numeric. &lt;BR /&gt;&lt;BR /&gt;If age was a character variable that code wouldn't work.</description>
      <pubDate>Thu, 16 Jan 2020 17:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617834#M19139</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-16T17:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macro stored as character but evaluated as numeric?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617835#M19140</link>
      <description>&lt;P&gt;You cannot combine or confuse macro variables with SAS variables. A macro variable is text, but that has nothing to do with how SAS uses it when SAS executes — SAS just replaces the macro variable with its value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The following code stores the number 30 into macro variable x, but it stores it as a character value, correct?&lt;/P&gt;
&lt;P&gt;Given that, how does the following where clause work?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; age&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;x&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when executed, &amp;amp;x is replaced by 30 and so this SAS code is perfectly valid&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where age&amp;gt;30;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 17:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617835#M19140</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-16T17:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro stored as character but evaluated as numeric?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617839#M19141</link>
      <description>&lt;P&gt;The same way that this where clause works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where age&amp;gt;30&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro PRE-processor just passes the generated text over to SAS to interpret. SAS will interpret the text the same way it would have interpreted the same text given to it directly from the program file.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 17:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617839#M19141</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-16T17:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro stored as character but evaluated as numeric?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617862#M19143</link>
      <description>&lt;P&gt;Thanks for the responses everyone!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 18:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-stored-as-character-but-evaluated-as-numeric/m-p/617862#M19143</guid>
      <dc:creator>jdsdog10</dc:creator>
      <dc:date>2020-01-16T18:42:49Z</dc:date>
    </item>
  </channel>
</rss>

