'Macro variable assign different value and generate the result for every value in the same macro variable

I just want to generate 4 table with one of the column with different value (pyanme), for example pyname1 is 1, pyname 2 is 2,pyname3 is 3, pyname 4 is 4. So that I assumed the result will be look likes this:

>   cust_ser   offier_id   1   2   3
>                   1
>                   1 
>                   1
>                   1
>                   2
>                   2
>                   2
>                   2
>                   3
>                   3
>                   3
>                   3
>                   4
>                   4
>                   4
>                   4

But I got the result is that all the value in offer_id is the value of %test(&pyname4). Does anymore can show me how to solve it, thanks.

Here is my code:

 %macro test(pyname);
     %gobal result 
    proc sql;
    create table1 as
     select a.cust_ser length=60,
            left(trim("&pyname") length=60 as offer_id,
            left(trim(b.class) length=200 as 1,
            left(trim(b.class_offer) length=200 as 2,
            left(trim(b.class_offer2) length=200 as 3,
     
     from abc    as a left join 
          _offer as b
    on a.cust_ser =b.cust_ser;
    quit;
     %put &pyname  &table1 ;
    %MEND; 
    %test(&pyname1);
    %test(&pyname2);
    %test(&pyname3);
    %test(&pyname4);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source