How to loop through a macro variable in SAS

sas

Solution

If you do

%put &deal_no;

you can see that it only contains the first value of `dealno`, not all of them. To avoid that you can do something like this:

proc sql;
    create table counter as select dealno from deal_table;
    select dealno into :deal_no_1 - :deal_no_&sqlobs
    from deal_table;
quit;

%let N = &sqlobs;

%macro loop;
%do i = 1 %to &N;
    %put &&deal_no_&i;
%end;
%mend;

%loop; run;

Problem

I have an example like this: ``` proc sql; select dealno into :deal_no from deal_table; ``` Now I want to traverse the variable `deal_no` now containing all dealno in table deal_table but I don't know how to do it.

Original source