<?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: macro variable during data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604184#M175128</link>
    <description>&lt;P&gt;its just because they are already macro variables. If there's a quick way to convert them to data values, that would be ok.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2019 16:53:04 GMT</pubDate>
    <dc:creator>Brian3</dc:creator>
    <dc:date>2019-11-14T16:53:04Z</dc:date>
    <item>
      <title>macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604152#M175110</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;the situation I have is a list of macro variables like follows;&lt;/P&gt;&lt;P&gt;var_2030&lt;/P&gt;&lt;P&gt;var_2031&lt;/P&gt;&lt;P&gt;var_2032&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;During the data step, which involves a loop, I need to use more than one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;x=2;&lt;/P&gt;&lt;P&gt;do i=1 to 3;&lt;/P&gt;&lt;P&gt;%let t=2030+i;&lt;/P&gt;&lt;P&gt;If x&amp;lt;&amp;amp;&amp;amp;var_&amp;amp;t then put 'success';&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, &amp;amp;&amp;amp;var_&amp;amp;t resolves as (var_2030) + i instead of (var_(2030+i)).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using %let t=%sysevalf(2030+i) but it then complains that there is a character variable instead of numeric. I also understand this may be related to macro values being evaluated before data steps are executed, so is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604152#M175110</guid>
      <dc:creator>Brian3</dc:creator>
      <dc:date>2019-11-14T16:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604153#M175111</link>
      <description>&lt;P&gt;From what you've posted here you should be using an array not a macro. &lt;BR /&gt;&lt;BR /&gt;That being macro variables are not resolved in the same step they're created. THere are many ways to get around this, but given that you don't need macros my first suggestion is to switch to arrays instead. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on using Arrays in SAS&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274283"&gt;@Brian3&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;the situation I have is a list of macro variables like follows;&lt;/P&gt;
&lt;P&gt;var_2030&lt;/P&gt;
&lt;P&gt;var_2031&lt;/P&gt;
&lt;P&gt;var_2032&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;During the data step, which involves a loop, I need to use more than one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;x=2;&lt;/P&gt;
&lt;P&gt;do i=1 to 3;&lt;/P&gt;
&lt;P&gt;%let t=2030+i;&lt;/P&gt;
&lt;P&gt;If x&amp;lt;&amp;amp;&amp;amp;var_&amp;amp;t then put 'success';&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, &amp;amp;&amp;amp;var_&amp;amp;t resolves as (var_2030) + i instead of (var_(2030+i)).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried using %let t=%sysevalf(2030+i) but it then complains that there is a character variable instead of numeric. I also understand this may be related to macro values being evaluated before data steps are executed, so is this possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks very much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604153#M175111</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-14T16:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604157#M175113</link>
      <description>&lt;P&gt;Your code can't run anyway because of syntax errors. You have a do without an end, and a % end without a %do.&lt;/P&gt;
&lt;P&gt;And if it was just a typo and it is a %do, that is not possible in open code, and I see no macro definition around your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what I can guess, I take it that you have a bad dataset design (wide instead of long/tall), forcing you to write complicated code for something that is most probably an extremely simple task in SAS, needing no macro code at all.&lt;/P&gt;
&lt;P&gt;So you first need to make your data intelligent (Maxim 33) by transposing; for further help, please provide example data in usable form (data step with datalines), and what you want to get as a result out of it.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604157#M175113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-14T16:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604165#M175115</link>
      <description>Thanks, for the task I'm doing I have to leave them as macro variables. Is there a way to do that?</description>
      <pubDate>Thu, 14 Nov 2019 16:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604165#M175115</guid>
      <dc:creator>Brian3</dc:creator>
      <dc:date>2019-11-14T16:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604166#M175116</link>
      <description>&lt;P&gt;There should not be a %. It should be end.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:23:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604166#M175116</guid>
      <dc:creator>Brian3</dc:creator>
      <dc:date>2019-11-14T16:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604171#M175118</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274283"&gt;@Brian3&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks, for the task I'm doing I have to leave them as macro variables. Is there a way to do that?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No. Macro variables are resolved during data step &lt;EM&gt;compilation&lt;/EM&gt;, so there's no way you can dynamically address them depending on values present while the data step &lt;EM&gt;executes&lt;/EM&gt;. This is a very typical beginner's misconception when they do not yet understand the nature of the macro language as a &lt;EM&gt;code generator&lt;/EM&gt;, not a data processing tool.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give us data and the expected result.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604171#M175118</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-14T16:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604172#M175119</link>
      <description>&lt;P&gt;Before trying to use macro code to generate SAS code first figure out want SAS code you want to run.&lt;/P&gt;
&lt;P&gt;It sounds like you want to do the following.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  success = .Z &amp;lt; x &amp;lt; max(of VAR_2030-VAR_2032);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if your variable names really are in that form of a common base and numeric suffix and you want all of them from some minimum suffix to some maximum suffix then you just need to two macro variables to how those two numbers to generate the code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let min=2030;
%let max=2032;
data want;
  set have ;
  success = .Z &amp;lt; x &amp;lt; max(of VAR_&amp;amp;min.-VAR_&amp;amp;max.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604172#M175119</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-14T16:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604179#M175123</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274283"&gt;@Brian3&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks, for the task I'm doing I have to leave them as macro variables. Is there a way to do that?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you need to provide a more representative sample of your issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604179#M175123</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-14T16:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604180#M175124</link>
      <description>&lt;P&gt;it is more the principle I am trying to do rather than specific data. Basically how to work with macro variables which can change value during a data step. Surely SAS has some ability to let me do that. Maybe I can use arrays, but not sure how it works with macro variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604180#M175124</guid>
      <dc:creator>Brian3</dc:creator>
      <dc:date>2019-11-14T16:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604182#M175126</link>
      <description>What makes you think you need macro variables at all.</description>
      <pubDate>Thu, 14 Nov 2019 16:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604182#M175126</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-14T16:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604184#M175128</link>
      <description>&lt;P&gt;its just because they are already macro variables. If there's a quick way to convert them to data values, that would be ok.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604184#M175128</guid>
      <dc:creator>Brian3</dc:creator>
      <dc:date>2019-11-14T16:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604186#M175130</link>
      <description>Use the macro variables to define your array definition then, which is dynamic and then you can use the array without any issues. First develop working code - non macro. If you show us what that looks like we can help you convert it to a macro. Right now we have an xy problem.</description>
      <pubDate>Thu, 14 Nov 2019 16:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604186#M175130</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-14T16:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604189#M175132</link>
      <description>&lt;P&gt;Hmm I've never used arrays before. Ok so&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;x=2;&lt;/P&gt;&lt;P&gt;%let var1=4;&lt;/P&gt;&lt;P&gt;%let var2=1;&lt;/P&gt;&lt;P&gt;%let var3=2;&lt;/P&gt;&lt;P&gt;array &amp;amp;var[3];&lt;/P&gt;&lt;P&gt;do i=1 to 2;&lt;/P&gt;&lt;P&gt;If x&amp;gt;&amp;amp;var[i] then put 'success';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604189#M175132</guid>
      <dc:creator>Brian3</dc:creator>
      <dc:date>2019-11-14T17:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604193#M175135</link>
      <description>&lt;P&gt;No need for an array there as you are just dealing with numeric constants and not variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var1=4;
%let var2=1;
%let var3=2;

data test;
  x=2;
  if x &amp;gt; min(&amp;amp;var1, &amp;amp;var2, &amp;amp;var3) then put 'success';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Much easier if you just put the list of values into a single macro variable instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list=4, 1, 2;

data test;
  x=2;
  if x &amp;gt; min(&amp;amp;list) then put 'success';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: Make sure to move your %LET statements BEFORE the DATA statement. That is when they will execute so placing them there in the code will be less confusing to you.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604193#M175135</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-14T17:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604195#M175137</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274283"&gt;@Brian3&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;it is more the principle I am trying to do rather than specific data. Basically how to work with macro variables which can change value during a data step. Surely SAS has some ability to let me do that. Maybe I can use arrays, but not sure how it works with macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You are still on the completely wrong path here. The macro language is a code generator, helping you in automatically writing dynamic code, but it is the wrong tool for dealing with data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to start learning the use of the macro language, you need to start with code that needs to be made dynamic to respond to certain outside conditions, not with data issues. For these you use arrays, retained variables, lag functions, look-ahead reading, hash objects, and so on.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604195#M175137</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-14T17:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604199#M175141</link>
      <description>&lt;P&gt;I've tried using arrays above.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604199#M175141</guid>
      <dc:creator>Brian3</dc:creator>
      <dc:date>2019-11-14T17:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604203#M175143</link>
      <description>&lt;P&gt;Here is an ARRAY example.&lt;/P&gt;
&lt;P&gt;First start with some data that has a series of similar variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input x y1-y5 ;
cards;
2 1 1 0 0 0 
1 1 2 3 4 5
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can use an ARRAY to reference the five "y" variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  array y y1-y5;
  success = x &amp;lt; min(of y[*]);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or by using an index into the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have;
  array y y1-y5 ;
  do index=1 to dim(y);
     if x &amp;lt; y[index] then put x= 'is less than ' y[index]=;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604203#M175143</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-14T17:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604204#M175144</link>
      <description>&lt;P&gt;ok sas is useless I'll just use data values and an array.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604204#M175144</guid>
      <dc:creator>Brian3</dc:creator>
      <dc:date>2019-11-14T17:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604206#M175145</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274283"&gt;@Brian3&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;ok sas is useless I'll just use data values and an array.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Exactly. Start by learning how to use SAS.&amp;nbsp; Once you understand how to do things in SAS you can then figure out how to use macro language to generate that code.&amp;nbsp; You cannot build a house without a solid foundation.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604206#M175145</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-14T17:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604207#M175146</link>
      <description>&lt;P&gt;If you want to create an array out of macro variables, see this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var1=4;
%let var2=1;
%let var3=2;

data test;
x = 2;
array var[3] (&amp;amp;var1, &amp;amp;var2, &amp;amp;var3);
do i = 1 to 3;
  If x &amp;gt; var[i] then put i ', success';
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the %let statements are now where they belong to reflect the point in time where they are resolved&lt;/LI&gt;
&lt;LI&gt;the macro variables are used at a&amp;nbsp;&lt;EM&gt;static&lt;/EM&gt; point resolved during data step compilation&lt;/LI&gt;
&lt;LI&gt;the array is defined correctly (without the erroneous macro variable reference)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-during-data-step/m-p/604207#M175146</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-14T17:39:53Z</dc:date>
    </item>
  </channel>
</rss>

