<?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 loop over with macrovariables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/loop-over-with-macrovariables/m-p/543942#M150379</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
      Proc sql;
create table				Autoreg_L6M_&amp;amp;t1  as 
select distinct						objectregnbr 

							,case when input(put(period,yymmn6.),best32.) GE &amp;amp;t6  then mean(depreciation) end as Mean_depreciation_L6m
					 


from						pricedata31
where						input(put(period,yymmn6.),best32.) GE &amp;amp;t6
and							input(put(period,yymmn6.),best32.) Le &amp;amp;t1 
group by					objectregnbr
;
Quit;

      Proc sql;
create table				Autoreg_L6M_&amp;amp;t2  as 
select distinct						objectregnbr 

							,case when input(put(period,yymmn6.),best32.) GE &amp;amp;t7  then mean(depreciation) end as Mean_depreciation_L6m
					 


from						pricedata31
where						input(put(period,yymmn6.),best32.) GE &amp;amp;t7
and							input(put(period,yymmn6.),best32.) LE &amp;amp;t2 
group by					objectregnbr
;
Quit;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you see this can get super repetitive with 36 months to go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are there any way to make this loop over and increase to the next macro variable?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Mar 2019 11:18:07 GMT</pubDate>
    <dc:creator>Kiteulf</dc:creator>
    <dc:date>2019-03-18T11:18:07Z</dc:date>
    <item>
      <title>loop over with macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-over-with-macrovariables/m-p/543942#M150379</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
      Proc sql;
create table				Autoreg_L6M_&amp;amp;t1  as 
select distinct						objectregnbr 

							,case when input(put(period,yymmn6.),best32.) GE &amp;amp;t6  then mean(depreciation) end as Mean_depreciation_L6m
					 


from						pricedata31
where						input(put(period,yymmn6.),best32.) GE &amp;amp;t6
and							input(put(period,yymmn6.),best32.) Le &amp;amp;t1 
group by					objectregnbr
;
Quit;

      Proc sql;
create table				Autoreg_L6M_&amp;amp;t2  as 
select distinct						objectregnbr 

							,case when input(put(period,yymmn6.),best32.) GE &amp;amp;t7  then mean(depreciation) end as Mean_depreciation_L6m
					 


from						pricedata31
where						input(put(period,yymmn6.),best32.) GE &amp;amp;t7
and							input(put(period,yymmn6.),best32.) LE &amp;amp;t2 
group by					objectregnbr
;
Quit;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you see this can get super repetitive with 36 months to go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are there any way to make this loop over and increase to the next macro variable?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 11:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-over-with-macrovariables/m-p/543942#M150379</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2019-03-18T11:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: loop over with macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-over-with-macrovariables/m-p/543943#M150380</link>
      <description>&lt;P&gt;The simple answer is don't model your data that way.&amp;nbsp; You are trying to use SAS like Excel with a transposed thinking.&amp;nbsp; Work with long (normalised data) and then transpose up only when needed, it will make your code faster and simpler.&amp;nbsp; If you produce some test data and show what you want out, I can show you.&amp;nbsp; The alternative is you either use array processing in a datastep (second on the list of recommendations), or thirdly write some macro loops - bad idea, dodgy coding, slow etc. not recommended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 11:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-over-with-macrovariables/m-p/543943#M150380</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-18T11:21:01Z</dc:date>
    </item>
  </channel>
</rss>

