<?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: Dynamic Macrovariable and counter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391544#M94056</link>
    <description>&lt;P&gt;I actully would like to receive a 10 random samples using the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;***assigning values of macrovariables seed1-seed10;&lt;BR /&gt;&lt;BR /&gt;data _null_;
	infile datalines dlm=',';
	input seedX @@;
		n+1;
		call symput('seed'!!strip(put(n,$2.)),strip(seedX));
datalines;
12345,23456,34567,45678,56789,67891,78912,89123,91234,92345
;
run;

options mprint;
&lt;BR /&gt;***macros for randomization from set mylib.team;
%macro team;

proc surveyselect data = mylib.team
	method = srs
	n = 100
	out = sample&amp;amp;i
	/*noprint*/
	seed=&amp;amp;&amp;amp;seed&amp;amp;i;
run; 

%mend team;
&lt;BR /&gt;***generation of 10 random samples, 100 persons each;
%do i=1 %to 10;
	%team;
%end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please have a look where is an error.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Aug 2017 16:06:40 GMT</pubDate>
    <dc:creator>DmytroYermak</dc:creator>
    <dc:date>2017-08-29T16:06:40Z</dc:date>
    <item>
      <title>Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391531#M94045</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help with the following issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to use the following cycle construction:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do i=1 %to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;% put seed&amp;amp;i=&amp;amp;&amp;amp;seed&amp;amp;i;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Definitely it is not correct now. I need to use current number of "i" in the construction "&amp;amp;i".&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my Symbol Table I have some values of seed1, seed2, ..., seed10. Please advise how to amend the code. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 15:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391531#M94045</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-08-29T15:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391532#M94046</link>
      <description>&lt;P&gt;Works fine for me, are you sure your macro variables are created and have the correct scope, ie global vs local if required?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into :name1-
from sashelp.class;
quit;

%macro demo;

%do i=1 %to 10;
         %put name&amp;amp;i=&amp;amp;&amp;amp;name&amp;amp;i;
%end;

%mend;

%demo;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;40 proc sql noprint;&lt;BR /&gt;41 select name into :name1-&lt;BR /&gt;42 from sashelp.class;&lt;BR /&gt;43 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt; real time 0.00 seconds&lt;BR /&gt; cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;44&lt;BR /&gt;45 %macro demo;&lt;BR /&gt;46&lt;BR /&gt;47 %do i=1 %to 10;&lt;BR /&gt;48 %put name&amp;amp;i=&amp;amp;&amp;amp;name&amp;amp;i;&lt;BR /&gt;49 %end;&lt;BR /&gt;50&lt;BR /&gt;51 %mend;&lt;BR /&gt;52&lt;BR /&gt;53 %demo;&lt;BR /&gt;name1=Alfred&lt;BR /&gt;name2=Alice&lt;BR /&gt;name3=Barbara&lt;BR /&gt;name4=Carol&lt;BR /&gt;name5=Henry&lt;BR /&gt;name6=James&lt;BR /&gt;name7=Jane&lt;BR /&gt;name8=Janet&lt;BR /&gt;name9=Jeffrey&lt;BR /&gt;name10=John&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 15:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391532#M94046</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-29T15:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391539#M94051</link>
      <description>&lt;P&gt;Thank you, Reeza! Do you mean that i is a macrovariable in a local table? I mean the the construction "%do i=1 %to 10"?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 15:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391539#M94051</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-08-29T15:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391540#M94052</link>
      <description>&lt;P&gt;I meant your seed macro variables, ie seed1 to seed10.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My 'guess' is that if they're not resolving it's a scope issue. But there could be other reasons. At any rate the code you posted is fine your error is somewhere else.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 15:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391540#M94052</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-29T15:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391542#M94054</link>
      <description>&lt;P&gt;The answer might very well lie in the code that you haven't shown, the "..." part:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do i = 1 %to 10;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That code could be changing the value of &amp;amp;i.&amp;nbsp; Here is a sneaky way that could happen.&amp;nbsp; If "..." includes a call to a macro (%abc), that macro might utilize a variable named &amp;amp;i.&amp;nbsp; If %abc fails to define &amp;amp;i as %local, then %abc will be using the &amp;amp;i in your loop (%do i=1 %to 10) instead of a new, %local version of &amp;amp;i.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 15:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391542#M94054</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-29T15:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391544#M94056</link>
      <description>&lt;P&gt;I actully would like to receive a 10 random samples using the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;***assigning values of macrovariables seed1-seed10;&lt;BR /&gt;&lt;BR /&gt;data _null_;
	infile datalines dlm=',';
	input seedX @@;
		n+1;
		call symput('seed'!!strip(put(n,$2.)),strip(seedX));
datalines;
12345,23456,34567,45678,56789,67891,78912,89123,91234,92345
;
run;

options mprint;
&lt;BR /&gt;***macros for randomization from set mylib.team;
%macro team;

proc surveyselect data = mylib.team
	method = srs
	n = 100
	out = sample&amp;amp;i
	/*noprint*/
	seed=&amp;amp;&amp;amp;seed&amp;amp;i;
run; 

%mend team;
&lt;BR /&gt;***generation of 10 random samples, 100 persons each;
%do i=1 %to 10;
	%team;
%end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please have a look where is an error.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 16:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391544#M94056</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-08-29T16:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391546#M94058</link>
      <description>&lt;P&gt;Doesn't your initial DATA step give you an error message?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Incorrect:&amp;nbsp;&amp;nbsp;&amp;nbsp; $2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Correct:&amp;nbsp;&amp;nbsp; 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can't express a numeric value in a character format.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 16:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391546#M94058</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-29T16:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391548#M94059</link>
      <description>Have you looked at the REP option in SurveySelect? Why do 10 iterations?</description>
      <pubDate>Tue, 29 Aug 2017 16:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391548#M94059</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-29T16:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391572#M94074</link>
      <description>I have to use 10 different "seed"s option in proc surveyselect and output them in different datasets. Is there another way to generate them?</description>
      <pubDate>Tue, 29 Aug 2017 16:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391572#M94074</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-08-29T16:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391574#M94076</link>
      <description>You are right - I have corrected the code. Thank you.</description>
      <pubDate>Tue, 29 Aug 2017 16:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391574#M94076</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-08-29T16:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391576#M94078</link>
      <description>&lt;P&gt;When I run my code I receive the following error:&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;1098 %do i=1 %to 10;
ERROR: The %DO statement is not valid in open code.
1099 %team;

MLOGIC(TEAM): Beginning execution.
WARNING: Apparent symbolic reference I not resolved.
NOTE 137-205: Line generated by the invoked macro "TEAM".
1 proc surveyselect data = mylib.team method = srs n = 100 out = sample&amp;amp;i seed=&amp;amp;&amp;amp;seed&amp;amp;i; run;
-
22
ERROR 22-322: Syntax error, expecting one of the following: ;, (, CERTAIN, CERTSIZE, CERTUNITS, DATA, GROUPS, JTPROBS, M, MAXSIZE, METHOD, MINSIZE, N, NMAX, NMIN, NOPRINT, OUT, OUTALL, OUTHITS, OUTSEED, OUTSIZE, OUTSORT, RANUNI,
RATE, REPS, SAMPRATE, SAMPSIZE, SEED, SELECTALL, SORT, SRSALG, STATS, STRATUMSEED.

WARNING: Apparent symbolic reference I not resolved.
WARNING: Apparent symbolic reference I not resolved.

NOTE: Line generated by the invoked macro "team".&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why is my structure '%do ... %to' not functioning?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 16:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391576#M94078</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-08-29T16:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391581#M94082</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/58513"&gt;@DmytroYermak&lt;/a&gt; wrote:&lt;BR /&gt;I have to use 10 different "seed"s option in proc surveyselect and output them in different datasets. Is there another way to generate them?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's not really going to give you different results than using the REP option, you can replicate it with the initial seed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 17:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391581#M94082</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-29T17:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391583#M94083</link>
      <description>&lt;P&gt;%DO is only permitted inside a macro definition.&amp;nbsp; If&amp;nbsp; you want to use it, you will need to define a macro holding your code, and run the macro.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 17:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391583#M94083</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-29T17:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391585#M94085</link>
      <description>&lt;P&gt;Where's your %macro statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you should post your FULL CODE and LOG now if you need further assistance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 17:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391585#M94085</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-29T17:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391590#M94088</link>
      <description>&lt;P&gt;Thank you! It resolves the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just one question. Is 'i' local or global macrovariable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here below is the full code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mylib 'C:\MYLIB_KP3';

data _null_;
	infile datalines dlm=',';
	input seedX @@;
		n+1;
		call symput('seed'!!strip(put(n,2.)),strip(seedX));
		datalines;
12345,23456,34567,45678,56789,67891,78912,89123,91234,92345
;
run;

%macro team;

	%do i=1 %to 10;

		proc surveyselect data = mylib.titanic
			method = srs
			n = 100
			out = sample&amp;amp;i
			noprint
			seed=&amp;amp;&amp;amp;seed&amp;amp;i;
		run;

	%end;

%mend team;

%team;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and the log:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1361  libname mylib 'C:\MYLIB_KP3';
NOTE: Libref MYLIB was successfully assigned as follows:
      Engine:        V9
      Physical Name: C:\MYLIB_KP3
1362
1363  data _null_;
1364      infile datalines dlm=',';
1365      input seedX @@;
1366          n+1;
1367          call symput('seed'!!strip(put(n,2.)),strip(seedX));
1368          datalines;

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      1367:52
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


1370  ;
1371  run;
1372
1373  %macro team;
1374
1375      %do i=1 %to 10;
1376
1377          proc surveyselect data = mylib.titanic
1378              method = srs
1379              n = 100
1380              out = sample&amp;amp;i
1381              noprint
1382              seed=&amp;amp;&amp;amp;seed&amp;amp;i;
1383          run;
1384
1385      %end;
1386
1387  %mend team;
1388
1389  %team;
MLOGIC(TEAM):  Beginning execution.
MLOGIC(TEAM):  %DO loop beginning; index variable I; start value is 1; stop value is 10; by value is 1.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample1 noprint seed=12345;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE1 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 2; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample2 noprint seed=23456;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE2 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 3; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample3 noprint seed=34567;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE3 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 4; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample4 noprint seed=45678;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE4 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 5; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample5 noprint seed=56789;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE5 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 6; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample6 noprint seed=67891;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE6 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 7; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample7 noprint seed=78912;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE7 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 8; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample8 noprint seed=89123;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE8 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 9; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample9 noprint seed=91234;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE9 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 10; loop will iterate again.
MPRINT(TEAM):   proc surveyselect data = mylib.titanic method = srs n = 100 out = sample10 noprint seed=92345;
MPRINT(TEAM):   run;

NOTE: The data set WORK.SAMPLE10 has 100 observations and 6 variables.
NOTE: PROCEDURE SURVEYSELECT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


MLOGIC(TEAM):  %DO loop index variable I is now 11; loop will not iterate again.
MLOGIC(TEAM):  Ending execution.
1390

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 17:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391590#M94088</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-08-29T17:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391595#M94091</link>
      <description>&lt;P&gt;&amp;amp;i should definitely be %local.&amp;nbsp; That avoids complications if a separate macro were to use &amp;amp;i, but that separate macro happens to invoke %team.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 17:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391595#M94091</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-29T17:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391601#M94095</link>
      <description>Done in my previous reply. Thank you for the help!</description>
      <pubDate>Tue, 29 Aug 2017 17:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391601#M94095</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-08-29T17:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Macrovariable and counter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391645#M94119</link>
      <description>&lt;LI-CODE lang="sas"&gt;&amp;lt;span class="token macrobound"&amp;gt;%macro&amp;lt;/span&amp;gt; team(seed)&amp;lt;span class="token punctuation"&amp;gt;;&amp;lt;/span&amp;gt;

&amp;lt;span class="token procnames"&amp;gt;proc&amp;lt;/span&amp;gt; &amp;lt;span class="token procnames"&amp;gt;surveyselect&amp;lt;/span&amp;gt; &amp;lt;span class="token procnames"&amp;gt;data&amp;lt;/span&amp;gt; &amp;lt;span class="token operator"&amp;gt;=&amp;lt;/span&amp;gt; mylib&amp;lt;span class="token punctuation"&amp;gt;.&amp;lt;/span&amp;gt;team
	method &amp;lt;span class="token operator"&amp;gt;=&amp;lt;/span&amp;gt; srs
	&amp;lt;span class="token function"&amp;gt;n&amp;lt;/span&amp;gt; &amp;lt;span class="token operator"&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class="token number"&amp;gt;100&amp;lt;/span&amp;gt;
	out &amp;lt;span class="token operator"&amp;gt;=&amp;lt;/span&amp;gt; sample&amp;lt;span class="token operator"&amp;gt;&amp;amp;&amp;lt;/span&amp;gt;i
	&amp;lt;span class="token comment"&amp;gt;/*noprint*/&amp;lt;/span&amp;gt;
	seed&amp;lt;span class="token operator"&amp;gt;=&amp;amp;seed&amp;lt;/span&amp;gt;&amp;lt;span class="token punctuation"&amp;gt;;&amp;lt;/span&amp;gt;
&amp;lt;span class="token procnames"&amp;gt;run&amp;lt;/span&amp;gt;&amp;lt;span class="token punctuation"&amp;gt;;&amp;lt;/span&amp;gt; 

&amp;lt;span class="token macrobound"&amp;gt;%mend&amp;lt;/span&amp;gt; team&amp;lt;span class="token punctuation"&amp;gt;;&amp;lt;/span&amp;gt;
&amp;lt;span class="token comment"&amp;gt;***generation of 10 random samples, 100 persons each;&amp;lt;br /&amp;gt;&amp;lt;/span&amp;gt;%macro do_loop(dimension);
&amp;lt;span class="token macrostatement"&amp;gt;%do&amp;lt;/span&amp;gt; i&amp;lt;span class="token operator"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="token number"&amp;gt;1&amp;lt;/span&amp;gt; &amp;lt;span class="token macrostatement"&amp;gt;%to&amp;lt;/span&amp;gt; &amp;lt;span class="token number"&amp;gt;&amp;amp;dimension&amp;lt;/span&amp;gt;&amp;lt;span class="token punctuation"&amp;gt;;&amp;lt;br /&amp;gt;&amp;lt;/span&amp;gt;    %put echo seed&amp;amp;i:&amp;amp;&amp;amp;seed&amp;amp;i;
    &amp;lt;span class="token macroname"&amp;gt;%team(&amp;amp;&amp;amp;seed&amp;amp;i)&amp;lt;/span&amp;gt;&amp;lt;span class="token punctuation"&amp;gt;;&amp;lt;/span&amp;gt;
&amp;lt;span class="token macrostatement"&amp;gt;%end&amp;lt;/span&amp;gt;&amp;lt;span class="token punctuation"&amp;gt;;&amp;lt;br /&amp;gt;%mend do_loop;&amp;lt;br /&amp;gt;%put _user_;&amp;lt;br /&amp;gt;%do_loop(1);*testing;&amp;lt;br /&amp;gt;%do_loop(10);*ok, then, run whole loop!;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/span&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;your two &lt;/FONT&gt;macro&lt;FONT face="courier new,courier"&gt; can be made easier to read if you have a parameter for &lt;/FONT&gt;macro&lt;FONT face="courier new,courier"&gt; team for the seed &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;this makes the macro named team, unique and &lt;/FONT&gt;unit-testable ,&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;rather than tied to the macro array in the global symbol table. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;this makes the macro with the loop easy to test and then ramp up to call the team macro.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;We, helpful volunteers, had no way of knowing,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;from the phrasing of your original question,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;where the error was:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1. in the code which generated the macro array&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;2. in the loop, which you thought was apparent to you&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;3. in the surveyselect macro&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;These ideas of separating the procedure from the loop for testing and development&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;were laid out by me and Art Carpenter in&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/List_Processing_Basics_Creating_and_Using_Lists_of_Macro_Variables" target="_self"&gt;http://www.sascommunity.org/wiki/List_Processing_Basics_Creating_and_Using_Lists_of_Macro_Variables&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ron Fehd&amp;nbsp; macro array maven&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 19:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Macrovariable-and-counter/m-p/391645#M94119</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2017-08-29T19:15:33Z</dc:date>
    </item>
  </channel>
</rss>

