<?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 series of macro variables. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901458#M356257</link>
    <description>Hello,&lt;BR /&gt;It worked perfectly. However, one more thing:&lt;BR /&gt;Is any way we can include your solution inside of this macro:&lt;BR /&gt;macro libname_yr;&lt;BR /&gt;%do  i = &amp;amp;start_yr  %to  &amp;amp;end_yr;&lt;BR /&gt;libname path&amp;amp;i   "  c:\a\i";&lt;BR /&gt;/*To add your piece here*/&lt;BR /&gt;.............................................&lt;BR /&gt;%mend libname_yr;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 03 Nov 2023 18:17:53 GMT</pubDate>
    <dc:creator>sascode</dc:creator>
    <dc:date>2023-11-03T18:17:53Z</dc:date>
    <item>
      <title>Create series of macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901449#M356254</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I need to create a series of macro variables to assign each year between two given years.&lt;/P&gt;
&lt;P&gt;For instance, without using any loop I have to assign them one by one:&lt;/P&gt;
&lt;P&gt;%let yr1= 2020;&lt;/P&gt;
&lt;P&gt;%let yr2= 2021;&lt;/P&gt;
&lt;P&gt;%let yr3= 2022;&lt;/P&gt;
&lt;P&gt;However, this is not very efficient , if range becomes wider.&lt;/P&gt;
&lt;P&gt;My idea is :&lt;BR /&gt;%let&amp;nbsp;start = 2010;&lt;/P&gt;
&lt;P&gt;%let end =&amp;nbsp; 2012;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.............................&lt;/P&gt;
&lt;P&gt;.............................&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 17:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901449#M356254</guid>
      <dc:creator>sascode</dc:creator>
      <dc:date>2023-11-03T17:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create series of macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901452#M356255</link>
      <description>&lt;P&gt;As always, context and purpose of these macro variables is important, and you don't tell us what the larger problem is or why you need these macro variables. I get the feeling that maybe there are easier ways where you won't need this sequence of macro variables, so please please please tell us what the larger problem is and why you need these macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, this is one way to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_yr=2010;
%let end_yr=2022;

data _null_;
    do i=1 to &amp;amp;end_yr-&amp;amp;start_yr+1;
        call symputx(cats("year",i),&amp;amp;start_yr+i-1);
    end;
run;

%put &amp;amp;=year1;
%put &amp;amp;=year2;
%put &amp;amp;=year13;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Nov 2023 18:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901452#M356255</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T18:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create series of macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901458#M356257</link>
      <description>Hello,&lt;BR /&gt;It worked perfectly. However, one more thing:&lt;BR /&gt;Is any way we can include your solution inside of this macro:&lt;BR /&gt;macro libname_yr;&lt;BR /&gt;%do  i = &amp;amp;start_yr  %to  &amp;amp;end_yr;&lt;BR /&gt;libname path&amp;amp;i   "  c:\a\i";&lt;BR /&gt;/*To add your piece here*/&lt;BR /&gt;.............................................&lt;BR /&gt;%mend libname_yr;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Nov 2023 18:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901458#M356257</guid>
      <dc:creator>sascode</dc:creator>
      <dc:date>2023-11-03T18:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create series of macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901459#M356258</link>
      <description>&lt;P&gt;Do you mean something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro libname_yr(start_yr=,end_yr=);
%local i ;

%do i = &amp;amp;start_yr %to &amp;amp;end_yr;
  /* libname path&amp;amp;i " c:\a\i"; */
  %local year%eval(&amp;amp;i-&amp;amp;start_yr+1) ; %*make it local or global ;
  %let year%eval(&amp;amp;i-&amp;amp;start_yr+1)=&amp;amp;i ;
%end ;

%put _local_ ;

%mend libname_yr;

%libname_yr(start_yr=2010,end_yr=2022)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will create macro variables like:&lt;/P&gt;
&lt;PRE&gt;14   %libname_yr(start_yr=2010,end_yr=2022)
LIBNAME_YR END_YR 2022
LIBNAME_YR I 2023
LIBNAME_YR START_YR 2010
LIBNAME_YR YEAR1 2010
LIBNAME_YR YEAR10 2019
LIBNAME_YR YEAR11 2020
LIBNAME_YR YEAR12 2021
LIBNAME_YR YEAR13 2022
LIBNAME_YR YEAR2 2011
LIBNAME_YR YEAR3 2012
LIBNAME_YR YEAR4 2013
LIBNAME_YR YEAR5 2014
LIBNAME_YR YEAR6 2015
LIBNAME_YR YEAR7 2016
LIBNAME_YR YEAR8 2017
LIBNAME_YR YEAR9 2018
&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 18:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901459#M356258</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-03T18:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create series of macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901464#M356260</link>
      <description>It worked perfectly.&lt;BR /&gt;Thank you for your help.</description>
      <pubDate>Fri, 03 Nov 2023 18:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901464#M356260</guid>
      <dc:creator>sascode</dc:creator>
      <dc:date>2023-11-03T18:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create series of macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901476#M356261</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215702"&gt;@sascode&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;It worked perfectly. However, one more thing:&lt;BR /&gt;Is any way we can include your solution inside of this macro:&lt;BR /&gt;macro libname_yr;&lt;BR /&gt;%do i = &amp;amp;start_yr %to &amp;amp;end_yr;&lt;BR /&gt;libname path&amp;amp;i " c:\a\i";&lt;BR /&gt;/*To add your piece here*/&lt;BR /&gt;.............................................&lt;BR /&gt;%mend libname_yr;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is why you should include the context of the problem in your original problem statement. Then I won't waste my time or your time on a DATA step solution.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 19:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901476#M356261</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T19:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create series of macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901516#M356271</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215702"&gt;@sascode&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;It worked perfectly. However, one more thing:&lt;BR /&gt;Is any way we can include your solution inside of this macro:&lt;BR /&gt;macro libname_yr;&lt;BR /&gt;%do i = &amp;amp;start_yr %to &amp;amp;end_yr;&lt;BR /&gt;libname path&amp;amp;i " c:\a\i";&lt;BR /&gt;/*To add your piece here*/&lt;BR /&gt;.............................................&lt;BR /&gt;%mend libname_yr;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why would you need a SERIES of macro variables if that is your code?&lt;/P&gt;
&lt;P&gt;What do you need besides the current YEAR which you for some reason called I instead of YEAR or YR in your code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2023 01:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-series-of-macro-variables/m-p/901516#M356271</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-04T01:04:28Z</dc:date>
    </item>
  </channel>
</rss>

