Convert table to variable

Viewed 23

I would like to convert a table of 1x1:

max
5

into a variable to do a for loop and searching on the internet I have not found anything.

To create a variable from a table (1x1):

proc sql noprint;
    select max into :macro_make
        from table;
quit;
%put &macro_make.;

And then do the loop to repeat a table n times:

data want;
    set have;
run;

%macro append(n);
    %do i = 1 %to (&n-1);
        Proc append base=want data=have;
        run;
    %end;
%mend append;

%append(&macro_make);

You know how can I deal with this?

1 Answers

Maybe I asked the question very soon because I have for want I wanted to do, so here it is. Just in case some want it in the future:

To create a variable from a table (1x1):

proc sql noprint;
    select max into :macro_make
        from table;
quit;
%put &macro_make.;

And then do the loop to repeat a table n times:

data want;
    set have;
run;

%macro append(n);
    %do i = 1 %to (&n-1);
        Proc append base=want data=have;
        run;
    %end;
%mend append;

%append(&macro_make);
Related