From: Tom Abernathy on
The CALL SYMPUT is not working because you are using single quote
characters instead of double quote characters to quote the name of the
macro variable you want to create. So the macro parameter IDNO is not
being expanded. Thus you are trying to tell CALL SYMPUT to create a
macro variable with an ampersand character in its name. Macro
variables can only use underscores and alphanumerics in their names.

Also if you need to reference the macro variable you define after the
macro has finished then you will need to make its scope extend beyond
the macro TEST. You could either define it before the macro call or
add a statement like:

%global rec&idno;

to the top of your macro.

- Tom

On Apr 21, 12:06 pm, maverick2 <phekuch...(a)gmail.com> wrote:
> I need to use proc sql into function OR call symput to define a macro
> variable. But this has to be done within a macro. So the macro
> variable being created has a macro parameter within it. I am unable to
> do this. Can this be done by any other method?
>
> %macro test (ds1, ds2, idno);
>
>        data &ds1.;
>             set &ds2.;
>             if <some condition>;
>         run;
>
>   data _null_;
>      set &ds2.;
>      if _n_ = 1 then do;
>          call symput ('rec&idno',var1);
>      end;
>   run;
>
> OR
>
> proc sql;
>
>         select var1 into: rec&idno
>         from &ds2.
>         where var2 = 1;      /* var2 = _n_ in &ds2.*/
>
> quit;
>
> %mend;
>
> %test (one, two, 10);
>
> %test (three, four, 40);
>
> Idea is to get macro variable rec10, rec40, etc. Obviously call symput
> and into function are not working, is there any way around this to
> define macro variables rec10, rec40 within the macro test?

From: shiva on
Hi,

Is this what your are expecting ..?

%macro test ;

data _null_;
set test;
call symput(compress('no'||_n_),var1);
run;
%mend;

%test;
%put &no4 or &no5;

Thanks,
-Shiva