<?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: Extract words from a string in one macro variable &amp;amp; place them into separate macro variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237376#M43509</link>
    <description>&lt;P&gt;Since VARLIST is already a macro variable, I guess you want to store the concatenated content of the macro variables in &amp;amp;VARLIST in a new macro variable, say, NAMELIST (which would contain &lt;STRONG&gt;rahul priya&lt;/STRONG&gt; in your example). This would require only a minor extension of your macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro maclist(varlist=);
  %local i nextword namelist;
  %let namelist=;
  %do i=1 %to %sysfunc(countw(&amp;amp;varlist));
    %let nextword = %scan(&amp;amp;varlist, &amp;amp;i);
    %put &amp;amp;nextword = &amp;amp;&amp;amp;&amp;amp;nextword;
    %let namelist=&amp;amp;namelist &amp;amp;&amp;amp;&amp;amp;nextword;
  %end;
  %put &amp;amp;namelist;
%mend maclist;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted to use &amp;amp;NAMELIST outside of the macro, you would have to remove &lt;FONT face="courier new,courier"&gt;namelist&lt;/FONT&gt;&amp;nbsp;from the %LOCAL statement and use a &lt;FONT face="courier new,courier"&gt;%GLOBAL namelist;&lt;/FONT&gt; statement instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Dec 2015 14:26:06 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2015-12-02T14:26:06Z</dc:date>
    <item>
      <title>Extract words from a string in one macro variable &amp; place them into separate macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237322#M43504</link>
      <description>&lt;P&gt;%macro putlog (varlist=);&lt;/P&gt;
&lt;P&gt;%local i nextword;&lt;/P&gt;
&lt;P&gt;%do i=1 %to %sysfunc(countw(&amp;amp;varlist));&lt;/P&gt;
&lt;P&gt;%let nextword = %scan(&amp;amp;varlist, &amp;amp;i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this readind the string how can i place the extracted string /word into a new macro variable?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 06:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237322#M43504</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2015-12-02T06:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words from a string in one macro variable &amp; place them into separate macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237324#M43505</link>
      <description>%macro maclist(varlist=);&lt;BR /&gt;%local i nextword;&lt;BR /&gt;  %do i=1 %to %sysfunc(countw(&amp;amp;varlist));&lt;BR /&gt;%let nextword = %scan(&amp;amp;varlist, &amp;amp;i);&lt;BR /&gt;%put &amp;amp;nextword = &amp;amp;&amp;amp;&amp;amp;nextword;&lt;BR /&gt;   %end;&lt;BR /&gt; %mend maclist;&lt;BR /&gt; %let rrt=rahul;&lt;BR /&gt; %let p=priya;&lt;BR /&gt; %maclist (varlist=rrt p);&lt;BR /&gt;&lt;BR /&gt;this my macro to read the (varlist=rrrt p) now how can i place varlist into new macro variable?</description>
      <pubDate>Wed, 02 Dec 2015 06:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237324#M43505</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2015-12-02T06:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words from a string in one macro variable &amp; place them into separate macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237376#M43509</link>
      <description>&lt;P&gt;Since VARLIST is already a macro variable, I guess you want to store the concatenated content of the macro variables in &amp;amp;VARLIST in a new macro variable, say, NAMELIST (which would contain &lt;STRONG&gt;rahul priya&lt;/STRONG&gt; in your example). This would require only a minor extension of your macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro maclist(varlist=);
  %local i nextword namelist;
  %let namelist=;
  %do i=1 %to %sysfunc(countw(&amp;amp;varlist));
    %let nextword = %scan(&amp;amp;varlist, &amp;amp;i);
    %put &amp;amp;nextword = &amp;amp;&amp;amp;&amp;amp;nextword;
    %let namelist=&amp;amp;namelist &amp;amp;&amp;amp;&amp;amp;nextword;
  %end;
  %put &amp;amp;namelist;
%mend maclist;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted to use &amp;amp;NAMELIST outside of the macro, you would have to remove &lt;FONT face="courier new,courier"&gt;namelist&lt;/FONT&gt;&amp;nbsp;from the %LOCAL statement and use a &lt;FONT face="courier new,courier"&gt;%GLOBAL namelist;&lt;/FONT&gt; statement instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 14:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237376#M43509</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-12-02T14:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words from a string in one macro variable &amp; place them into separate macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237777#M43612</link>
      <description>@freelance expected output is 2 new macro variables:&lt;BR /&gt;Var1  = rahul&lt;BR /&gt;Var2  = priya&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Dec 2015 10:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237777#M43612</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2015-12-04T10:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words from a string in one macro variable &amp; place them into separate macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237778#M43613</link>
      <description>@freelance when i pass a string to maclist macro then each word in that string should be stored in the separate macro variables</description>
      <pubDate>Fri, 04 Dec 2015 11:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237778#M43613</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2015-12-04T11:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words from a string in one macro variable &amp; place them into separate macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237791#M43622</link>
      <description>&lt;P&gt;First, &lt;STRONG&gt;don't do it&lt;/STRONG&gt;. You already have the values in the list, just use the list.&lt;/P&gt;
&lt;P&gt;But if you really need to do it and reference the new variables after the macro ends then you need to do something to make sure the new variables are not defined as local to the macro that is creating them. Adding a %GLOBAL statement is one way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro parselist(varlist);
%local i nextvar;
%do i=1 %to %sysfunc(countw(&amp;amp;varlist));
  %let nextvar=word&amp;amp;i;
  %global &amp;amp;nextvar;
  %let &amp;amp;nextvar= %scan(&amp;amp;varlist, &amp;amp;i);
%end;
%mend parselist;
%parselist(A B);
%put &amp;amp;word1 &amp;amp;word2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Dec 2015 12:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-from-a-string-in-one-macro-variable-amp-place-them/m-p/237791#M43622</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-12-04T12:03:28Z</dc:date>
    </item>
  </channel>
</rss>

