<?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: How to copy one macro variable data to another macro variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509023#M1722</link>
    <description>&lt;P&gt;Hi&amp;nbsp;KurtBremser&lt;SPAN class="login-bold"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thank you so much for the reply.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;I don't have any issue with put statement or data step. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;It is the issue with scan function. when I used scan function in %let statement then that is not working.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;I would like to know the reason why that is not working or am I missing anything.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thanks &amp;amp; Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Bhanuprakash Pala&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Oct 2018 07:23:21 GMT</pubDate>
    <dc:creator>bhanuprakash</dc:creator>
    <dc:date>2018-10-31T07:23:21Z</dc:date>
    <item>
      <title>How to copy one macro variable data to another macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509005#M1717</link>
      <description>&lt;P&gt;By using the below I am passing one macro variable. It has multiple words. Based on number of words loop will execute and each time one word should be resolved and that should be the macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see the below codes and let me know why second one is not working.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;* Working ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%macro test(var_names=) ;&lt;BR /&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;var_names.)) ;&lt;BR /&gt;%put "&amp;amp;i." ;&lt;BR /&gt;var_main = scan(&amp;amp;var_names.,&amp;amp;i.) ; output ;&lt;BR /&gt;%end ;&lt;BR /&gt;%mend test ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data testing ;&lt;BR /&gt;%test(var_names = %str("bhanu prakash")) ;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;* Not working ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro test(var_names=) ;&lt;BR /&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;var_names.)) ;&lt;BR /&gt;%put "&amp;amp;i." ;&lt;BR /&gt;%let var_main = %scan(&amp;amp;var_names.,&amp;amp;i.) ;&lt;BR /&gt;%put &amp;amp;var_main. ;&lt;BR /&gt;%end ;&lt;BR /&gt;%mend test ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data testing ;&lt;BR /&gt;%test(var_names = %str("bhanu prakash")) ;&lt;BR /&gt;run ;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 06:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509005#M1717</guid>
      <dc:creator>bhanuprakash</dc:creator>
      <dc:date>2018-10-31T06:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy one macro variable data to another macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509016#M1718</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124649"&gt;@bhanuprakash&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;By using the below I am passing one macro variable. It has multiple words. Based on number of words loop will execute and each time one word should be resolved and that should be the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see the below codes and let me know why second one is not working.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;* Working ;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;%macro test(var_names=) ;&lt;BR /&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;var_names.)) ;&lt;BR /&gt;%put "&amp;amp;i." ;&lt;BR /&gt;var_main = scan(&amp;amp;var_names.,&amp;amp;i.) ; output ;&lt;BR /&gt;%end ;&lt;BR /&gt;%mend test ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data testing ;&lt;BR /&gt;%test(var_names = %str("bhanu prakash")) ;&lt;BR /&gt;run ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;* Not working ;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro test(var_names=) ;&lt;BR /&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;var_names.)) ;&lt;BR /&gt;%put "&amp;amp;i." ;&lt;BR /&gt;%let var_main = %scan(&amp;amp;var_names.,&amp;amp;i.) ;&lt;BR /&gt;%put &amp;amp;var_main. ;&lt;BR /&gt;%end ;&lt;BR /&gt;%mend test ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data testing ;&lt;BR /&gt;%test(var_names = %str("bhanu prakash")) ;&lt;BR /&gt;run ;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maxim 1: read the documentation, in this case of the %put macro statement.&lt;/P&gt;
&lt;P&gt;All it does is write text to the log; if &amp;amp;var_main is not already present in the global symbol table, it will be local to the macro, and its contents lost when the macro stops executing.&lt;/P&gt;
&lt;P&gt;The first macro is actually &lt;EM&gt;creating&lt;/EM&gt; something, namely the code that writes observations to the dataset. The second macro creates nothing, so you end up with this data step code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Oct 2018 06:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509016#M1718</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-31T06:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy one macro variable data to another macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509023#M1722</link>
      <description>&lt;P&gt;Hi&amp;nbsp;KurtBremser&lt;SPAN class="login-bold"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thank you so much for the reply.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;I don't have any issue with put statement or data step. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;It is the issue with scan function. when I used scan function in %let statement then that is not working.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;I would like to know the reason why that is not working or am I missing anything.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thanks &amp;amp; Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Bhanuprakash Pala&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 07:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509023#M1722</guid>
      <dc:creator>bhanuprakash</dc:creator>
      <dc:date>2018-10-31T07:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy one macro variable data to another macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509026#M1724</link>
      <description>&lt;P&gt;Maxim 2: read the log. In this context, "read" also means "understand and interpret".&lt;/P&gt;
&lt;PRE&gt;37         data testing ;
38         %test(var_names = %str("bhanu prakash")) ;
"1"
ERROR: Literal contains unmatched quote.
ERROR: The macro TEST will stop executing.
39         run ;
&lt;/PRE&gt;
&lt;P&gt;Keep in mind that the macro preprocessor is a pure &lt;EM&gt;text&lt;/EM&gt; processor; everything is text to it, including quotes(!).&lt;/P&gt;
&lt;P&gt;%scan dissects the string &lt;EM&gt;with the masked quotes&lt;/EM&gt; at the blank, and so you get&lt;/P&gt;
&lt;PRE&gt;"bhanu&lt;/PRE&gt;
&lt;P&gt;as the first result, which is a literal with an unmatched quote.&lt;/P&gt;
&lt;P&gt;Text strings in macros need no quotes, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(var_names=) ;
%do i = 1 %to %sysfunc(countw(&amp;amp;var_names.)) ;
%put "&amp;amp;i." ;
%let var_main = %scan(&amp;amp;var_names.,&amp;amp;i.) ;
%put &amp;amp;var_main. ;
%end ;
%mend test ;

%test(var_names = bhanu prakash) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since the macro does not create any data step code, the data step itself is not needed.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 07:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509026#M1724</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-31T07:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy one macro variable data to another macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509029#M1725</link>
      <description>Sorry for the silly question and Thank you so much for the brief explanation.</description>
      <pubDate>Wed, 31 Oct 2018 08:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509029#M1725</guid>
      <dc:creator>bhanuprakash</dc:creator>
      <dc:date>2018-10-31T08:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy one macro variable data to another macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509030#M1726</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124649"&gt;@bhanuprakash&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry for the silly question and Thank you so much for the brief explanation.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A question can't be silly if you learn something from it.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 08:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-copy-one-macro-variable-data-to-another-macro-variable/m-p/509030#M1726</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-31T08:27:52Z</dc:date>
    </item>
  </channel>
</rss>

