<?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: Iteratively pass each row of a data file to a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815372#M321838</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I am trying to understand how the accuracy of microneurography data is influenced by these two parameters. Is this the higher level you are after?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's a good start. Now explain the math (at a high level) that you need to do on this data.&lt;/P&gt;</description>
    <pubDate>Fri, 27 May 2022 10:24:51 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-05-27T10:24:51Z</dc:date>
    <item>
      <title>Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/814988#M321703</link>
      <description>&lt;P&gt;Hi SAS Forum,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I am a new user, and I want to pass rows from a data file into a macro. However I have no idea how to do this without hard coding. Is there a better way?&lt;BR /&gt;&lt;BR /&gt;To try and explain what I want to do, lets say I have a data file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data datafile;
input parm1 parm2;
datalines;
1.1 2.0
1.2 2.0&lt;BR /&gt;1.3 2.0&lt;BR /&gt;1.4 2.0
;
run;&lt;/PRE&gt;&lt;P&gt;And I have a macro that takes two inputs and produces a data set:&lt;/P&gt;&lt;PRE&gt;%macro mymacro(input1=,input2=);

[does stuff...] 

data output;
run;

%end
%mend&lt;/PRE&gt;&lt;P&gt;Then I want to somehow iteratively pass each row of &lt;FONT face="batang,apple gothic"&gt;datafile&lt;/FONT&gt; into the inputs of the macro &lt;FONT face="batang,apple gothic"&gt;mymacro&lt;/FONT&gt;, and at each row get a new data &lt;FONT face="batang,apple gothic"&gt;output&lt;/FONT&gt;. At the end, I want to concatenate these output data files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this (but obviously this is not working!):&lt;/P&gt;&lt;PRE&gt;data test;
set %mymacro(input1=parm1,input2=parm2)
run;&lt;/PRE&gt;&lt;P&gt;Any help on how I would go about this? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 07:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/814988#M321703</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-25T07:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815343#M321826</link>
      <description>&lt;P&gt;At first write the code without any macro statements. Think about the creating the dataset "output", what happens to the dataset if you would call it again? Right, the dataset will be overwritten, so you get only the output of the last call. Why do you need to process the data of each observation separately? What exactly happens in "mymacro"? If you need to call a macro from within a data step, have a look at call execute, you will need it.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 07:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815343#M321826</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-05-27T07:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815348#M321828</link>
      <description>&lt;P&gt;You could use DOSUBL on each row to run the macro on the values of each row. Something like this (UNTESTED CODE):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set datafile;
    x=dosubl("%mymacro(input1="||parm1||",input2="||parm2||")");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A real-world example from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt; is here: &lt;A href="https://blogs.sas.com/content/sasdummy/2016/02/15/using-proc-iomoperate/" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/sasdummy/2016/02/15/using-proc-iomoperate/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 09:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815348#M321828</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-27T09:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815349#M321829</link>
      <description>&lt;P&gt;Hi Andreas,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for the help. I am not sure how call execute could be implemented for this problem. This is what I have written so far - it might help you understand what I am trying to do.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data sample;
	input param1 param2;
  	datalines;
  	1.0 1.5
	;
run;

data _null_;
	set sample;
  	call symput("x",param1);
  	call symput("y",param2);
run;

%put param1 is = &amp;amp;x;
%put param2 is = &amp;amp;y;

%mymacro(parameter1=&amp;amp;x,parameter2=&amp;amp;y,outputfileidx=01);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I want is for the data sample to have multiple lines, which I can iteratively pass to %mymacro&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 09:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815349#M321829</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T09:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815350#M321830</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/426087"&gt;@linlin87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Andreas,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks for the help. I am not sure how call execute could be implemented for this problem. This is what I have written so far - it might help you understand what I am trying to do.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data sample;
	input param1 param2;
  	datalines;
  	1.0 1.5
	;
run;

data _null_;
	set sample;
  	call symput("x",param1);
  	call symput("y",param2);
run;

%put param1 is = &amp;amp;x;
%put param2 is = &amp;amp;y;

%mymacro(parameter1=&amp;amp;x,parameter2=&amp;amp;y,outputfileidx=01);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want is for the data sample to have multiple lines, which I can iteratively pass to %mymacro&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The DOSUBL idea I provided above should work, but there may be simpler methods that you ought to consider first. Exactly what is the problem you are trying to solve? At this time, please explain in words, not via SAS code.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 09:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815350#M321830</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-27T09:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815351#M321831</link>
      <description>&lt;P&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for helping.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro is running a correlation of performance metrics for a device. It calls a data set, changes two parameters (param1 and param2) in this dataset, calculates the performance metrics, and outputs a dataset. I want to investigate how this performance metric depends on a large sample space of param1 and param2. I hope this answers your question?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%mymacro(param1=RAND('normal'),param2=RAND('normal'),call=01);&lt;/PRE&gt;&lt;P&gt;because then I can just have a %do loop and repeatedly call this. But I actually get very strange results when I take this approach. The output is different to if I manually enter the values from RAND('normal').&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 09:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815351#M321831</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T09:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815352#M321832</link>
      <description>Thanks Paige, I will try this.</description>
      <pubDate>Fri, 27 May 2022 09:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815352#M321832</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T09:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815355#M321833</link>
      <description>Hi Paige,&lt;BR /&gt;&lt;BR /&gt;The issue as that the output I am interested in extracting from %mymacro is a dataset.&lt;BR /&gt;&lt;BR /&gt;How would you apply dosubl in this instance?</description>
      <pubDate>Fri, 27 May 2022 10:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815355#M321833</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T10:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815361#M321834</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/426087"&gt;@linlin87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Paige,&lt;BR /&gt;&lt;BR /&gt;The issue as that the output I am interested in extracting from %mymacro is a dataset.&lt;BR /&gt;&lt;BR /&gt;How would you apply dosubl in this instance?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, I want a high level explanation of what this problem is. Not with reference to SAS code or SAS data sets or SAS macros. What is your data, what is the real-world problem you are trying to solve? What are the logical steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have already given example code.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 10:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815361#M321834</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-27T10:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815362#M321835</link>
      <description>I should add, Andreas, that my macro has a third parameter, so the data file has an index on each run, namely:&lt;BR /&gt;&lt;BR /&gt;%mymacro(1.02,12.5,01)&lt;BR /&gt;&lt;BR /&gt;produces a dataset output_01&lt;BR /&gt;</description>
      <pubDate>Fri, 27 May 2022 10:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815362#M321835</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T10:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815371#M321837</link>
      <description>&lt;P&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand how the accuracy of microneurography data is influenced by these two parameters. Is this the higher level you are after?&lt;BR /&gt;&lt;BR /&gt;I can see you have provided code, which works - thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now have the following:&lt;/P&gt;&lt;PRE&gt;data datafile;
input parm1 parm2;
datalines;
1.1 2.0
1.2 2.0
1.3 2.0
1.4 2.0
;
run;

data _null_;
    set datafile;
	x=dosubl("%mymacro(input1="||parm1||",input2="||parm2||")");
run;&lt;/PRE&gt;&lt;P&gt;but how do I deal with the fact that at every iteration of %mymacro I am overwriting the data file that is generated? I introduced a new variable into the macro which appends an index to the file at each run, and then added a do loop to the data step, but it isn't doing what I expect:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;data _null_;
    set datafile;
    	do i=1 to 5;
		x=dosubl("%mymacro(input1="||parm1||",input2="||parm2||",file_id=i)");
		end;
run;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I introduce&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 10:23:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815371#M321837</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T10:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815372#M321838</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I am trying to understand how the accuracy of microneurography data is influenced by these two parameters. Is this the higher level you are after?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's a good start. Now explain the math (at a high level) that you need to do on this data.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 10:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815372#M321838</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-27T10:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815373#M321839</link>
      <description>&lt;P&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure of bias/difference between the microneurography sensor and a reference electrode. I am changing the parameters of the calibration of the sensor (param1 and param2) and then recalculating the bias between this recalibrated sensor and the reference electrode.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 10:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815373#M321839</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T10:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815382#M321842</link>
      <description>&lt;P&gt;Thanks. I think that helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you say:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;but it isn't doing what I expect:&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This never helps. When you say something isn't working &lt;EM&gt;and provide no additional information&lt;/EM&gt;, we can't help further. We don't know what you did, we don't know what happened, we don't know what it is doing and we don't know what you expect.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So if there are errors in the log ... you need to show us the &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ENTIRE&lt;/FONT&gt; &lt;/STRONG&gt;log (not selected parts) for this DATA step (or PROC). You need to copy the log as text and then paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66123iA4EF494F9CA0F6EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" alt="2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If there are no errors but the output isn't right, then EXPLAIN, and show us the incorrect output and describe the output you'd like.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 10:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815382#M321842</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-27T10:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815383#M321843</link>
      <description>&lt;P&gt;ADDING: sometimes, when we ask, people say something like: "I want to compute the mean and standard deviation on each row" and then we tell them there are much simpler ways to do this without using macros or DOSUBL on each row. Now that you have explained, I think you are correct that this probably should be done by running a macro on each row.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 10:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815383#M321843</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-27T10:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815386#M321845</link>
      <description>&lt;P&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I now have is below. It is not producing the&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data datafile;
input parm1 parm2;
datalines;
1.1 2.0
1.2 2.0
1.3 2.0
;
run;

%macro mymacro(input1=,input2=,file_id=);
*[code for recomputing bias];

data output_&amp;amp;file_id;
set output_final;
run;

%mend;

data _null_;
    set datafile;
    	do i=1 to 3;
	x=dosubl("%mymacro(input1="||parm1||",input2="||parm2||",file_id=&amp;amp;i)");
	end;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2022 10:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815386#M321845</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T10:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815387#M321846</link>
      <description>&lt;P&gt;And the error is:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;WARNING: Apparent symbolic reference I not resolved.
22: LINE and COLUMN cannot be determined.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and
              COLUMN where the error has occurred.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;,
              _DATA_, _LAST_, _NULL_.
200: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN
      where the error has occurred.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.OUTPUT_ may be incomplete.  When this step was stopped there
         were 0 observations and 6 variables.
WARNING: Data set WORK.OUTPUT_ was not replaced because this step was stopped.
WARNING: The data set WORK.I may be incomplete.  When this step was stopped there were 0
         observations and 6 variables.
WARNING: Data set WORK.I was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2022 10:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815387#M321846</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-05-27T10:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815389#M321847</link>
      <description>&lt;P&gt;You can't use macro variable &amp;amp;i because you have never defined it (this macro variable does not exist).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code seems to use a DO loop that doesn't make sense to me, and was not present in my original code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set datafile;
    	do i=1 to 3;
	x=dosubl("%mymacro(input1="||parm1||",input2="||parm2||",file_id=&amp;amp;i)");
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try this instead&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set datafile;
    x=dosubl("%mymacro(input1="||parm1||",input2="||parm2||",file_id="||_n_||")");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2022 11:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815389#M321847</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-27T11:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815390#M321848</link>
      <description>&lt;P&gt;Would suggest changing Paige's example to have single quotes around the macro call.&amp;nbsp; This will prevent the macro call from resolving too early. Suggest:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set datafile;
    x=dosubl('%mymacro(input1='||parm1||",input2="||parm2||",file_id="||_n_||")");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2022 11:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815390#M321848</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-05-27T11:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively pass each row of a data file to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815391#M321849</link>
      <description>&lt;P&gt;This is a great question.&amp;nbsp; You're new to SAS (?) my guess is not new to programming.&amp;nbsp; If you're really new to SAS or new to the macro language, I think you should take the time to work this through in steps.&amp;nbsp; And read a few papers (search lexjansen.com for "CALL EXECUTE and macro"). I would rephrase your question as "how do I use DATA to generate macro calls, rather than type macro calls myself." So this is data-driven programming, using data ("control tables") to generate code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paige has recommended DOSUBL.&amp;nbsp; I would recommend the older CALL EXECUTE, which is similar, but should be a bit easier to learn because it shows more information in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, with any macro development you need to start with working SAS code, and then move to working macro code.&amp;nbsp; You have that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data output_final ;
  set sashelp.class ;
run ;

%macro mymacro(input1=,input2=,file_id=);
  *[code for recomputing bias];

  %put RUNNING %nrstr(%mymacro) with parameters &amp;amp;=input1 &amp;amp;=input2 &amp;amp;=file_id  ;

  data output_&amp;amp;file_id;
    set output_final;
  run;
%mend;

%mymacro(input1=1.1,input2=2.0,file_id=1)
%mymacro(input1=1.2,input2=2.0,file_id=2)
%mymacro(input1=1.3,input2=2.0,file_id=3)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So make sure you get to the point where your can write three macro calls, and get the output you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After that, you move on to generating three macro calls from data, instead of typing the macro calls.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Within a DATA step, you can use the DOSUBL function or the CALL EXECUTE routine to generate SAS code, in this case generate macro calls.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datafile;
input parm1 parm2;
datalines;
1.1 2.0
1.2 2.0
1.3 2.0
;
run;

data _null_;
  set datafile;
  **x=dosubl(
           '%mymacro(input1='||put(parm1,8.1)||",input2="||put(parm2,8.1)||",file_id="||put(_n_,8.)||")" 
           );

  call execute(
               '%nrstr(%mymacro)(input1='||put(parm1,8.1)||",input2="||put(parm2,8.1)||",file_id="||put(_n_,8.)||")"
           );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code for CALL EXECUTE is a bit uglier than DOSUBL because you need to add %NRSTR() to delay macro execution a bit.&amp;nbsp; But the benefit is CALL EXECUTE will show you the generated code in the log.&amp;nbsp; So in this case, you can see that CALL EXECUTE generated the three macro calls you intended:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;29   data _null_;
30     set datafile;
31     **x=dosubl(
32              '%mymacro(input1='||put(parm1,8.1)||",input2="||put(parm2,8.1)||",file_id="||put(_
32 ! n_,8.)||")"
33              );
34
35     call execute(
36                  '%nrstr(%mymacro)(input1='||put(parm1,8.1)||",input2="||put(parm2,8.1)||",file
36 ! _id="||put(_n_,8.)||")"
37              );
38   run;

NOTE: There were 3 observations read from the data set WORK.DATAFILE.

NOTE: CALL EXECUTE generated line.
MPRINT(MYMACRO):   *[code for recomputing bias];
1   + %mymacro(input1=     1.1,input2=     2.0,file_id=       1)
RUNNING %mymacro with parameters INPUT1=1.1 INPUT2=2.0 FILE_ID=1
MPRINT(MYMACRO):   data output_1;
MPRINT(MYMACRO):   set output_final;
MPRINT(MYMACRO):   run;

NOTE: There were 19 observations read from the data set WORK.OUTPUT_FINAL.
NOTE: The data set WORK.OUTPUT_1 has 19 observations and 5 variables.

MPRINT(MYMACRO):   *[code for recomputing bias];
2   + %mymacro(input1=     1.2,input2=     2.0,file_id=       2)
RUNNING %mymacro with parameters INPUT1=1.2 INPUT2=2.0 FILE_ID=2
MPRINT(MYMACRO):   data output_2;
MPRINT(MYMACRO):   set output_final;
MPRINT(MYMACRO):   run;

NOTE: There were 19 observations read from the data set WORK.OUTPUT_FINAL.
NOTE: The data set WORK.OUTPUT_2 has 19 observations and 5 variables.

MPRINT(MYMACRO):   *[code for recomputing bias];
3   + %mymacro(input1=     1.3,input2=     2.0,file_id=       3)
RUNNING %mymacro with parameters INPUT1=1.3 INPUT2=2.0 FILE_ID=3
MPRINT(MYMACRO):   data output_3;
MPRINT(MYMACRO):   set output_final;
MPRINT(MYMACRO):   run;

NOTE: There were 19 observations read from the data set WORK.OUTPUT_FINAL.
NOTE: The data set WORK.OUTPUT_3 has 19 observations and 5 variables.
&lt;/PRE&gt;
&lt;P&gt;The macro language is inherently complex, because you're writing macro language code to generate SAS code.&amp;nbsp; Data-driven programming with macros is complex-er because your writing SAS code to generate macro language calls that generate SAS code.&amp;nbsp; If you work on it in steps (working SAS code, working macro calls, working generation of macro calls), it is much easier to debug when things break or give surprising results.&amp;nbsp; Because you can test whether the SAS code works, then test whether hand written macro calls work, then check whether you are actually generating the same macro calls as you are writing by hand.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 11:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-pass-each-row-of-a-data-file-to-a-macro/m-p/815391#M321849</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-05-27T11:54:03Z</dc:date>
    </item>
  </channel>
</rss>

