<?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 Next1,Next2,......macro variables from vector macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776043#M246727</link>
    <description>&lt;P&gt;Let's start with this vector and create base and next1...next6&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Later it will be nice also to learn creating vector in smarter way&lt;/P&gt;</description>
    <pubDate>Sat, 23 Oct 2021 17:46:07 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2021-10-23T17:46:07Z</dc:date>
    <item>
      <title>Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776040#M246725</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is the way to create macro variables base,next1,next2,next3,next4,next5,next6 with shorter code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vector=2101+2102+2103+2104+2105+2106+2107;&lt;BR /&gt;%let n=%sysfunc(countw(&amp;amp;vector,'+'));
%let base = %scan(&amp;amp;vector,0,’+’);
%let Next1 = %scan(&amp;amp;vector,1,’+’);
%let Next2 = %scan(&amp;amp;vector,2,’+’);
%let Next3 = %scan(&amp;amp;vector,3,’+’);
%let Next4 = %scan(&amp;amp;vector,4,’+’);
%let Next5 = %scan(&amp;amp;vector,5,’+’);
%let Next6 = %scan(&amp;amp;vector,6,’+’);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 17:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776040#M246725</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-23T17:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776042#M246726</link>
      <description>&lt;P&gt;Do you want to create the vector macro variable smarter as well?&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 17:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776042#M246726</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-10-23T17:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776043#M246727</link>
      <description>&lt;P&gt;Let's start with this vector and create base and next1...next6&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Later it will be nice also to learn creating vector in smarter way&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 17:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776043#M246727</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-23T17:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776044#M246728</link>
      <description>&lt;P&gt;I assume that you want to create the vector from some data, and you don't really need the vector macro variable anyways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   do v = 2101 to 2107;
      output;
   end;
run;

proc sql noprint;
   select v into : next1 - 
   from have;
   %let n = &amp;amp;sqlobs.;
quit;

%put &amp;amp;n.;
%put &amp;amp;next1;
%put &amp;amp;&amp;amp;next&amp;amp;n;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Oct 2021 17:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776044#M246728</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-10-23T17:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776045#M246729</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;What is the meaning of "Next1-"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 18:39:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776045#M246729</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-23T18:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776046#M246730</link>
      <description>&lt;P&gt;Good question. Next1 is the name of the first macro variable that will be created. Since we do not (necessarily) know how many values are in the input data set (and therefore how many macro variables should be created) PROC SQL lets us omit the second part by simply coding the "-" with nothing behind it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, the code is similar to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
   select v into : next1 - next7
   from have;
   %let n = &amp;amp;sqlobs.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Oct 2021 18:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776046#M246730</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-10-23T18:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776062#M246739</link>
      <description>&lt;P&gt;What do you mean by "vector"?&lt;/P&gt;
&lt;P&gt;What is you are planning to do with this list of values?&lt;/P&gt;
&lt;P&gt;Why is that made easier instead of harder by creating all of those macro variables with similar names?&lt;/P&gt;</description>
      <pubDate>Sun, 24 Oct 2021 04:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776062#M246739</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-24T04:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776074#M246745</link>
      <description>&lt;P&gt;Great questions from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; . I look forward to hearing the answers from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition I would add that if these are months (2101 through 2107) then they should be handled as months instead of character strings. There are many benefits to handling months as months, for example if you ever need then next month after 2112, then it is 2201 rather than 2113, SAS makes this pretty easy, they have done the programming to handle months so you don't have to; but if you handle these as text strings you have to write your own logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How does one start a problem with a macro variable that has a value of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;2101+2102+2103+2104+2105+2106+2107&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to me that lately you are starting with unusual macro variables, which are the cause of your problem, and if you had taken a different path, the whole problem could be bypassed. In my mind, macro variables come from calculations (for example, what month is six months before today? what is the mean value of X? does file ABC exist?), or by extracting data from databases or datasets. I can't imagine a problem where you start with a macro variable that has the value of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;2101+2102+2103+2104+2105+2106+2107&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and so my advice to you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt; is that you are working hard to get somewhere, and then you get stuck, and it would be easier to not go there in the first place, and we can help you with this, if only we knew what the big picture was (which you haven't told us). This is called the &lt;A href="https://xyproblem.info/" target="_self"&gt;X-Y problem&lt;/A&gt;&amp;nbsp;and is not uncommon, and it seems to me that this is often the real problem in your questions.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Oct 2021 10:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776074#M246745</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-24T10:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776151#M246790</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;did this solve your problem?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 09:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776151#M246790</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-10-25T09:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create Next1,Next2,......macro variables from vector macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776211#M246817</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Great questions from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; . I look forward to hearing the answers from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition I would add that if these are months (2101 through 2107) then they should be handled as months instead of character strings. There are many benefits to handling months as months, for example if you ever need then next month after 2112, then it is 2201 rather than 2113, SAS makes this pretty easy, they have done the programming to handle months so you don't have to; but if you handle these as text strings you have to write your own logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;I believe I may have pointed this out the OP more than 2 years ago. Maybe even more than once. Continued to do everything with that YYMM format. I also remember a set of questions related to dealing with intervals or similar uses of the values where repeatedly the first step was to create data values so the calculations could be done.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 15:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Next1-Next2-macro-variables-from-vector-macro-variable/m-p/776211#M246817</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-25T15:00:38Z</dc:date>
    </item>
  </channel>
</rss>

