<?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 keep in macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486134#M126419</link>
    <description>&lt;P&gt;You can set the value of&amp;nbsp;&lt;STRONG&gt;name&lt;/STRONG&gt; in a macro variable by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;%lat name =&amp;nbsp;&lt;SPAN&gt;sas communities;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or create it in your step by&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data main;
name='sas communities' ;
call symput ('NAME', name);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Anyhow, what to you mean by "every letter of name variable" ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please post your target.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Aug 2018 09:19:06 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2018-08-12T09:19:06Z</dc:date>
    <item>
      <title>how to keep in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486127#M126413</link>
      <description>&lt;P&gt;data main;&lt;/P&gt;&lt;P&gt;name='sas communities' ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to keep&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;in macro variable every letter of name variable?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Aug 2018 07:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486127#M126413</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-08-12T07:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486134#M126419</link>
      <description>&lt;P&gt;You can set the value of&amp;nbsp;&lt;STRONG&gt;name&lt;/STRONG&gt; in a macro variable by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;%lat name =&amp;nbsp;&lt;SPAN&gt;sas communities;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or create it in your step by&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data main;
name='sas communities' ;
call symput ('NAME', name);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Anyhow, what to you mean by "every letter of name variable" ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please post your target.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Aug 2018 09:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486134#M126419</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-08-12T09:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486135#M126420</link>
      <description>Every letter in that string</description>
      <pubDate>Sun, 12 Aug 2018 09:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486135#M126420</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-08-12T09:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486141#M126426</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Every letter in that string&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Run &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;'s code, and you'll see that it works. Show at least a&amp;nbsp;&lt;EM&gt;little&lt;/EM&gt; initiative on your part, please.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Aug 2018 10:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486141#M126426</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-12T10:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486143#M126427</link>
      <description>&lt;P&gt;To assign every letter of the string in a separate macro variable you need a loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;either:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro  mac_name(string);
     %do n=1 %to %length(&amp;amp;string);
             %let L&amp;amp;n = %substr(&amp;amp;string, &amp;amp;n,1);

     %end;
%mend mac_name;
%mac_name(sas comunities);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    name = 'sas comunities';
   
    do n=1 to length(name);
        call symput('L'||n , substr(name,n,1);
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to check results run next code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;L1 &amp;amp;L2 &amp;amp;L3 ... &amp;amp;LX;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Aug 2018 10:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486143#M126427</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-08-12T10:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486153#M126435</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data main;
name="sas communities";
new=compress(name);
do i = 1 to length(new);
var=substr(new,i,1);
output;
end;
run;

proc sql;
select var into: var1 - from main;
quit;


%put &amp;amp;var1 &amp;amp;var2 &amp;amp;var3 &amp;amp;var4;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Aug 2018 13:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486153#M126435</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-12T13:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486154#M126436</link>
      <description>Use %do %substr</description>
      <pubDate>Sun, 12 Aug 2018 13:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486154#M126436</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-08-12T13:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486160#M126439</link>
      <description>&lt;P&gt;You will need to define a macro, since %DO is not allowed outside of a macro.&amp;nbsp; So within a macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let name = sas communities;&lt;/P&gt;
&lt;P&gt;%local k next_letter;&lt;/P&gt;
&lt;P&gt;%global letter_list;&lt;/P&gt;
&lt;P&gt;%let letter_list=;&lt;/P&gt;
&lt;P&gt;%do k = 1 %to %length (&amp;amp;name);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%let next_letter = %substr(&amp;amp;name, &amp;amp;k, 1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%if %index(&amp;amp;name, &amp;amp;next_letter) = 0 %then %let name = &amp;amp;name&amp;amp;next_letter;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final value of &amp;amp;LETTER_LIST will be a list of all the letters found in &amp;amp;NAME, with duplicates eliminated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why is it that you are trying to use macros?&amp;nbsp; It was only a few weeks ago that you were struggling with basic SAS language questions.&amp;nbsp; It is probably too early to worry about macros.&amp;nbsp; Your time would be better spent learning more SAS skills first.&amp;nbsp; If it appeals to you, I could give you a list of topics to learn.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Aug 2018 15:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-keep-in-macro-variable/m-p/486160#M126439</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-12T15:19:03Z</dc:date>
    </item>
  </channel>
</rss>

