<?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: Create macro var with values separated by space in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817737#M322766</link>
    <description>&lt;P&gt;Use the TRANSLATE function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector2=%sysfunc(translate,&amp;amp;vector1,%str( ),%str(,));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Jun 2022 10:14:38 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-06-13T10:14:38Z</dc:date>
    <item>
      <title>Create macro var with values separated by space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817736#M322765</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Let's say that user define a macro var called vector1 that contain values separated by comma.&lt;/P&gt;
&lt;P&gt;The task is to create another macro variable called vector2 that contain same values as vector 1 but values separated by space&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector1='RFA07','RFA02','RFA04','BRG92','PER1903';
/*Task-Create macro variable Vector2 that will be equal to
 'RFA07'   'RFA02'   'RFA04'   'BRG92'   'PER1903'*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 10:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817736#M322765</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-06-13T10:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro var with values separated by space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817737#M322766</link>
      <description>&lt;P&gt;Use the TRANSLATE function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector2=%sysfunc(translate,&amp;amp;vector1,%str( ),%str(,));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 10:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817737#M322766</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-13T10:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro var with values separated by space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817739#M322768</link>
      <description>&lt;P&gt;Thanks,get error&lt;/P&gt;
&lt;PRE&gt;26         %let Vector1='RFA07','RFA02','RFA04','BRG92','PER1903';
27         %let Vector2=%sysfunc(translate,&amp;amp;vector1,%str( ),%str(,));
ERROR: Expected open parenthesis after macro function name not found.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 10:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817739#M322768</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-06-13T10:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro var with values separated by space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817742#M322771</link>
      <description>&lt;P&gt;I messed up the parentheses. Why don't you try to fix them?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 10:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817742#M322771</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-13T10:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro var with values separated by space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817744#M322772</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector1='RFA07','RFA02','RFA04','BRG92','PER1903';
%let Vector2 = %sysfunc(translate(%quote(&amp;amp;Vector1),' ',','));
%put &amp;amp;Vector1;
%put &amp;amp;Vector2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 10:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817744#M322772</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-06-13T10:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro var with values separated by space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817747#M322774</link>
      <description>&lt;P&gt;Try this.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector1='RFA07','RFA02','RFA04','BRG92','PER1903';
%let Vector2=%sysfunc(tranwrd(%quote(&amp;amp;vector1),%str(,),%str( )));
%put &amp;amp;=vector1 &amp;amp;=vector2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         %let Vector1='RFA07','RFA02','RFA04','BRG92','PER1903';
 70         %let Vector2=%sysfunc(tranwrd(%quote(&amp;amp;vector1),%str(,),%str( )));
 71         %put &amp;amp;=vector1 &amp;amp;=vector2;
 VECTOR1='RFA07','RFA02','RFA04','BRG92','PER1903' VECTOR2='RFA07' 'RFA02' 'RFA04' 'BRG92' 'PER1903'
 72         
 73         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 10:33:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817747#M322774</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-13T10:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro var with values separated by space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817756#M322783</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector1='RFA07','RFA02','RFA04','BRG92','PER1903';
%let Vector2 = %sysfunc(translate(%quote(&amp;amp;Vector1),' ',','));
%put &amp;amp;Vector1;
%put &amp;amp;Vector2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You want the last two arguments of the TRANSLATE function to be enclosed in %str( ) and not single-quotes. While it works in this case, it may not work in other cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector2 = %sysfunc(translate(%quote(&amp;amp;Vector1),%str( ),%str(,)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 11:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-var-with-values-separated-by-space/m-p/817756#M322783</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-13T11:33:09Z</dc:date>
    </item>
  </channel>
</rss>

