<?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 create a macro variable from interactive macro variables? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-create-a-macro-variable-from-interactive-macro-variables/m-p/4698#M1896</link>
    <description>Hi:&lt;BR /&gt;
  This isn't really an ODS or BASE Reporting Procedure question. However, here's a quick example to point you in the right direction.&lt;BR /&gt;
 &lt;BR /&gt;
  To concatenate macro variables together, you would do something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
*** concatenate macro variable example;&lt;BR /&gt;
   &lt;BR /&gt;
%let one = kermit;&lt;BR /&gt;
%let two = the;&lt;BR /&gt;
%let three = frog;&lt;BR /&gt;
    &lt;BR /&gt;
%put ******** check resolution **********;&lt;BR /&gt;
%put one=&amp;amp;one two=&amp;amp;two three=&amp;amp;three;&lt;BR /&gt;
   &lt;BR /&gt;
%let phrase = &amp;amp;one &amp;amp;two &amp;amp;three;&lt;BR /&gt;
%let alt = &amp;amp;one, &amp;amp;two$ &amp;amp;three!!!;&lt;BR /&gt;
&lt;BR /&gt;
%put ******** check resolution **********;&lt;BR /&gt;
%put phrase=&amp;amp;phrase       alt=&amp;amp;alt;&lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
And then in the SAS log, you will see the following:&lt;BR /&gt;
[pre]&lt;BR /&gt;
499  *** concatenate macro variable example;&lt;BR /&gt;
500&lt;BR /&gt;
501  %let one = kermit;&lt;BR /&gt;
502  %let two = the;&lt;BR /&gt;
503  %let three = frog;&lt;BR /&gt;
504&lt;BR /&gt;
505  %put ******** check resolution **********;&lt;BR /&gt;
******** check resolution **********&lt;BR /&gt;
506  %put one=&amp;amp;one two=&amp;amp;two three=&amp;amp;three;&lt;BR /&gt;
one=kermit two=the three=frog&lt;BR /&gt;
507&lt;BR /&gt;
508  %let phrase = &amp;amp;one &amp;amp;two &amp;amp;three;&lt;BR /&gt;
509  %let alt = &amp;amp;one, &amp;amp;two$ &amp;amp;three!!!;&lt;BR /&gt;
510&lt;BR /&gt;
511  %put ******** check resolution **********;&lt;BR /&gt;
******** check resolution **********&lt;BR /&gt;
512  %put phrase=&amp;amp;phrase       alt=&amp;amp;alt;&lt;BR /&gt;
phrase=kermit the frog       alt=kermit, the$ frog!!!&lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Note how the punctuation (, $ !!!) in the %let statement:&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let alt = &amp;amp;one&lt;B&gt;,&lt;/B&gt; &amp;amp;two&lt;B&gt;$&lt;/B&gt; &amp;amp;three&lt;B&gt;!!!&lt;/B&gt;;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
gets put into the new macro variable &amp;amp;ALT:&lt;BR /&gt;
[pre]&lt;BR /&gt;
    alt=kermit&lt;B&gt;,&lt;/B&gt; the&lt;B&gt;$&lt;/B&gt; frog&lt;B&gt;!!!&lt;/B&gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
    &lt;BR /&gt;
For more help with this task, for example, using a MACRO %DO loop or using %IF or writing a macro program to automatically validate and build your new macro variable, your best bet for help is to read the SAS Macro documentation or to contact Tech Support: &lt;A href="http://support.sas.com/techsup/contact/index.html" target="_blank"&gt;http://support.sas.com/techsup/contact/index.html&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Fri, 14 Sep 2007 15:28:05 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2007-09-14T15:28:05Z</dc:date>
    <item>
      <title>How to create a macro variable from interactive macro variables?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-create-a-macro-variable-from-interactive-macro-variables/m-p/4697#M1895</link>
      <description>I'm working on an interactive query system and I need help:&lt;BR /&gt;
&lt;BR /&gt;
I have several macro variables that will be passed on from the query interface when a user makes a multiple-year selection for the year variable. The system will create the following macro variables:&lt;BR /&gt;
&lt;BR /&gt;
%let year0=4;&lt;BR /&gt;
%let year=1;&lt;BR /&gt;
%let year1=1996;&lt;BR /&gt;
%let year2=1998;&lt;BR /&gt;
%let year3=2001;&lt;BR /&gt;
%let year4=2005;&lt;BR /&gt;
&lt;BR /&gt;
The number and values of the macro variables above may be different at different times. For instance, for a different query that is submitted, the macro variables could be as follows:&lt;BR /&gt;
&lt;BR /&gt;
%let year0=3;&lt;BR /&gt;
%let year=1;&lt;BR /&gt;
%let year1=1996;&lt;BR /&gt;
%let year2=1997;&lt;BR /&gt;
%let year3=2002;&lt;BR /&gt;
&lt;BR /&gt;
For example, I want to create a new macro variable (named "yearnew") that has a value of (1996,1998,2001,2005) for the first query submitted to our system but then the value of the macro variable for the second query submitted would be:  (1996,1997,2002)&lt;BR /&gt;
&lt;BR /&gt;
So I plan to create this “yearnew” macro variable so that I can use it in a subsequent macro program.&lt;BR /&gt;
&lt;BR /&gt;
Thanks a million for your help.</description>
      <pubDate>Fri, 14 Sep 2007 14:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-create-a-macro-variable-from-interactive-macro-variables/m-p/4697#M1895</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-09-14T14:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a macro variable from interactive macro variables?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-create-a-macro-variable-from-interactive-macro-variables/m-p/4698#M1896</link>
      <description>Hi:&lt;BR /&gt;
  This isn't really an ODS or BASE Reporting Procedure question. However, here's a quick example to point you in the right direction.&lt;BR /&gt;
 &lt;BR /&gt;
  To concatenate macro variables together, you would do something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
*** concatenate macro variable example;&lt;BR /&gt;
   &lt;BR /&gt;
%let one = kermit;&lt;BR /&gt;
%let two = the;&lt;BR /&gt;
%let three = frog;&lt;BR /&gt;
    &lt;BR /&gt;
%put ******** check resolution **********;&lt;BR /&gt;
%put one=&amp;amp;one two=&amp;amp;two three=&amp;amp;three;&lt;BR /&gt;
   &lt;BR /&gt;
%let phrase = &amp;amp;one &amp;amp;two &amp;amp;three;&lt;BR /&gt;
%let alt = &amp;amp;one, &amp;amp;two$ &amp;amp;three!!!;&lt;BR /&gt;
&lt;BR /&gt;
%put ******** check resolution **********;&lt;BR /&gt;
%put phrase=&amp;amp;phrase       alt=&amp;amp;alt;&lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
And then in the SAS log, you will see the following:&lt;BR /&gt;
[pre]&lt;BR /&gt;
499  *** concatenate macro variable example;&lt;BR /&gt;
500&lt;BR /&gt;
501  %let one = kermit;&lt;BR /&gt;
502  %let two = the;&lt;BR /&gt;
503  %let three = frog;&lt;BR /&gt;
504&lt;BR /&gt;
505  %put ******** check resolution **********;&lt;BR /&gt;
******** check resolution **********&lt;BR /&gt;
506  %put one=&amp;amp;one two=&amp;amp;two three=&amp;amp;three;&lt;BR /&gt;
one=kermit two=the three=frog&lt;BR /&gt;
507&lt;BR /&gt;
508  %let phrase = &amp;amp;one &amp;amp;two &amp;amp;three;&lt;BR /&gt;
509  %let alt = &amp;amp;one, &amp;amp;two$ &amp;amp;three!!!;&lt;BR /&gt;
510&lt;BR /&gt;
511  %put ******** check resolution **********;&lt;BR /&gt;
******** check resolution **********&lt;BR /&gt;
512  %put phrase=&amp;amp;phrase       alt=&amp;amp;alt;&lt;BR /&gt;
phrase=kermit the frog       alt=kermit, the$ frog!!!&lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Note how the punctuation (, $ !!!) in the %let statement:&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let alt = &amp;amp;one&lt;B&gt;,&lt;/B&gt; &amp;amp;two&lt;B&gt;$&lt;/B&gt; &amp;amp;three&lt;B&gt;!!!&lt;/B&gt;;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
gets put into the new macro variable &amp;amp;ALT:&lt;BR /&gt;
[pre]&lt;BR /&gt;
    alt=kermit&lt;B&gt;,&lt;/B&gt; the&lt;B&gt;$&lt;/B&gt; frog&lt;B&gt;!!!&lt;/B&gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
    &lt;BR /&gt;
For more help with this task, for example, using a MACRO %DO loop or using %IF or writing a macro program to automatically validate and build your new macro variable, your best bet for help is to read the SAS Macro documentation or to contact Tech Support: &lt;A href="http://support.sas.com/techsup/contact/index.html" target="_blank"&gt;http://support.sas.com/techsup/contact/index.html&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 14 Sep 2007 15:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-create-a-macro-variable-from-interactive-macro-variables/m-p/4698#M1896</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-09-14T15:28:05Z</dc:date>
    </item>
  </channel>
</rss>

