<?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: why you can't use a macro funcation like %scan inside of a data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359294#M274511</link>
    <description>&lt;P&gt;Hmm is a="%scan(&amp;amp;a,2_)" equivlent to a= "'"||%scan(&amp;amp;a,2,_)||"'"&lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2017 08:26:30 GMT</pubDate>
    <dc:creator>gyambqt</dc:creator>
    <dc:date>2017-05-17T08:26:30Z</dc:date>
    <item>
      <title>why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359265#M274492</link>
      <description>&lt;P&gt;Hi I think this is a very basic question.&lt;/P&gt;
&lt;P&gt;why I can't use %scan or some other macro function inside of a datastep.&lt;/P&gt;
&lt;P&gt;Is this because data step is reading value from PDV and %scan is creating a text?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(a_b);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;a= "'"||&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;a&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)||"'";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder why the above program won't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please provide detailed explaination and refer me to any document if it is relevant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 07:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359265#M274492</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2017-05-17T07:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359267#M274493</link>
      <description>All about timing&lt;BR /&gt;Compile time :  is macro time&lt;BR /&gt;Run time : observation time</description>
      <pubDate>Wed, 17 May 2017 07:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359267#M274493</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-05-17T07:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359269#M274494</link>
      <description>&lt;P&gt;The macro processor is a &lt;EM&gt;&lt;STRONG&gt;pre-&lt;/STRONG&gt;&lt;/EM&gt;processor. Anytime the SAS interpreter encounters a macro trigger (&amp;amp; or %), it sends all text of the trigger to the macro processor. This then deals with it and returns (or not, ie if a %put just writes to the log) text to the SAS interpreter for further execution.&lt;/P&gt;
&lt;P&gt;So all macro triggers are resolved &lt;U&gt;before&lt;/U&gt; a data or procedure step starts to run.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 07:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359269#M274494</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-17T07:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359270#M274495</link>
      <description>&lt;P&gt;As a general rule use %scan when you are writing macro code statements and use the SCAN function in SAS code. Believe me it's a lot easier that way and it works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let a=%str(a_b);
 
data a;
  a = scan("&amp;amp;a", 2, "_");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 07:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359270#M274495</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-05-17T07:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359271#M274496</link>
      <description>&lt;P&gt;It's partly what you mentioned (processing text vs. processing data in the PDV). &amp;nbsp;But it's more than that. &amp;nbsp;Macro language constructs your program. &amp;nbsp;It doesn't process your data. &amp;nbsp;Picture this stand-alone statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let b&lt;/FONT&gt; =&amp;nbsp;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;a&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Macro language would process the text "a", and would return a null string since there is no second word within the text "a".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the context of your&amp;nbsp;program, macro language does the same thing. &amp;nbsp;It processes "a" before your DATA step begins to run, as part of the process of compiling the DATA step statements and determining what statements should become part of the DATA step. &amp;nbsp;If you wanted macro language to return "b" instead (the second word within "a_b", you could get that with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let a = a_b;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let b&lt;/FONT&gt; =&amp;nbsp;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;a&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;But none of that processing takes place within a DATA step. &amp;nbsp;All of it takes place as part of the compilation process that determines what statements the DATA step contains. &amp;nbsp;So consider your original program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let a = a_b;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data a;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;a= "'"||&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;a&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)"'";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%SCAN runs before the DATA step begins, and generates this program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;data a;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;a= "'"||&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;"'";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The bottom line: &amp;nbsp;macro language constructs a program. &amp;nbsp;It doesn't process your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 07:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359271#M274496</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-17T07:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359274#M274497</link>
      <description>Of course, there always exception to rules. &lt;BR /&gt;So the RESOLVE() data step function invokes the macro language environment processor to "resolve" the string parameter as if it is macro language syntax. &lt;BR /&gt;This use of the macro language provides a very different performance to the macro language processing which occurs in the usual way. This becomes most obvious when you think about doing the "resolve" on every data step iteration.... imagine a 100 million row table through a data step using RESOLVE()</description>
      <pubDate>Wed, 17 May 2017 07:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359274#M274497</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-05-17T07:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359275#M274498</link>
      <description>&lt;P&gt;I wonder why %scan below can't resolved to "b"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a = a_b;&lt;BR /&gt;data a;&lt;BR /&gt;a= "'"||%scan(a,2,_)"'";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;i thought %scan would be &amp;nbsp;resolved to b before data step get executed.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 07:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359275#M274498</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2017-05-17T07:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359278#M274499</link>
      <description>&lt;P&gt;Sorry I had a typo error . The code is fixed now.&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 07:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359278#M274499</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2017-05-17T07:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359279#M274500</link>
      <description>&lt;BR /&gt;If you want to use macro variable A then it must be prefixed with &amp;amp;&lt;BR /&gt;Your code is referring to data variable A&lt;BR /&gt;</description>
      <pubDate>Wed, 17 May 2017 07:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359279#M274500</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-05-17T07:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359280#M274501</link>
      <description>Yeah I fixed the code now. But it still didn't work</description>
      <pubDate>Wed, 17 May 2017 07:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359280#M274501</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2017-05-17T07:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359281#M274502</link>
      <description>&lt;P&gt;Even in your fixed code, a means a. &amp;nbsp;It's just a letter. It has no connection to any variable in any DATA step. &amp;nbsp;Macro language doesn't require quotes for it to treat characters as text. &amp;nbsp;That's the default interpretation: &amp;nbsp;characters are text whether they have quotes around them or not.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359281#M274502</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-17T08:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359285#M274503</link>
      <description>The base SAS language provides two stages for processing&lt;BR /&gt;1 deriving syntax (called macro language processing)&lt;BR /&gt;2 processing data in the data step iteration (or running a procedure like FREQ)&lt;BR /&gt;There is no need to make the functionality of one of these "stages", do both jobs.&lt;BR /&gt;</description>
      <pubDate>Wed, 17 May 2017 08:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359285#M274503</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-05-17T08:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359286#M274504</link>
      <description>&lt;P&gt;I don't quite understand.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't&amp;nbsp;%scan(&amp;amp;a,2,_) resolved to &amp;nbsp;%scan(a_b,2,_) further resolved to b?&lt;/P&gt;
&lt;P&gt;b with quotation should be treated as value?&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359286#M274504</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2017-05-17T08:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359287#M274505</link>
      <description>did you try&lt;BR /&gt;  &lt;BR /&gt;%let a = a_b;&lt;BR /&gt;data a;&lt;BR /&gt;a= "%scan(&amp;amp;a,2,_)" ;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 17 May 2017 08:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359287#M274505</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-05-17T08:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359288#M274506</link>
      <description>&lt;P&gt;Yeah but the % inside of double quotation won't get processed properly.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359288#M274506</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2017-05-17T08:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359289#M274507</link>
      <description>&lt;P&gt;The ONE IMPORTANT question has not yet been asked: what are you trying to achieve? Do you want to parameterize the use of a &lt;U&gt;data step variable&lt;/U&gt; in a data step, or do you want to parameterize a &lt;U&gt;value&lt;/U&gt; in a data step?&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359289#M274507</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-17T08:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359290#M274508</link>
      <description>&lt;P&gt;In macro language, b is not a value. &amp;nbsp;b is a letter that might be part of a SAS statement. &amp;nbsp;For example, after generating b with the %SCAN function, you would have this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a = a_b;&lt;/P&gt;
&lt;P&gt;%let b = %scan(&amp;amp;a, 2, _);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro variable &amp;amp;b contains the letter b. &amp;nbsp;But if it were part of this DATA step statement that would cause a problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a = a_b;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data a;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a= "'"||%scan(&amp;amp;a,2,_)"'";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The DATA step statement would look like this:'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;a = "'" ||b"'";&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That's not a valid DATA step statement.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359290#M274508</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-17T08:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359292#M274509</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12983"&gt;@gyambqt&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Yeah but the % inside of double quotation won't get processed properly.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Nonsense. Double quotes are exactly what's needed to resolve macro triggers:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let a=%str(a_b); /* is equivalent to %let a=a_b; */

data a;
a = "%scan(&amp;amp;a,2,_)";
run;

proc print data=a;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Dataset a contains the value "b" in variable a.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359292#M274509</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-17T08:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359293#M274510</link>
      <description>&lt;P&gt;But if I didn't use the || to concanate quotation mark together around b , I believe the treat b as a variable rather than value.&lt;/P&gt;
&lt;P&gt;but here I used || so the final resolved value should be a='b'..... am I wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a= "'"||%scan(&amp;amp;a,2,_)||"'";&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359293#M274510</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2017-05-17T08:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: why you can't use a macro funcation like %scan inside of a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359294#M274511</link>
      <description>&lt;P&gt;Hmm is a="%scan(&amp;amp;a,2_)" equivlent to a= "'"||%scan(&amp;amp;a,2,_)||"'"&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-you-can-t-use-a-macro-funcation-like-scan-inside-of-a-data/m-p/359294#M274511</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2017-05-17T08:26:30Z</dc:date>
    </item>
  </channel>
</rss>

