0
votes

I am new to sas and have the following macro call:
%test (input1=&lib._2015, input2=&lib.base, out=out_data_2016)

Now, I want a loop that in the next step the output_data_2016 are used as input1 and create a new out variable out_data_2017. The call then should look like:
%test (input1=out_data_2016, input2=&lib.base, out_data_2017).

Thanks in advance!

edit:
I have several years to observe (say 2010 till 2018). Then I need 9 macro calls:

%test (input1=&lib._2014, input2=&lib.base, out=out_data_2015) %test (input1=&lib._2015, input2=&lib.base, out=out_data_2016) %test (input1=out_data_2016, input2=&lib.base, out_data_2017) etc.

My hope is to create a loop, so that I need only one step, but I do not know why...

1
How is that a loop? It is just two macro calls. - Tom

1 Answers

1
votes

Please read through the SAS documentation, write some code and post a new question around what you tried.

%DO, Iterative Statement

Executes a section of a macro repetitively based on the value of an index variable.

Type: Macro statement

Restriction: Allowed in macro definitions only (my emphasis)

See also: %END Statement

…

Syntax

%DO macro-variable=start %TO stop <%BY increment>; text and macro language statements %END;