hello. i want to insert macro variable in the middle of specific word.
example is as follows...
%macro test(name=);
proc sql;
create table.&namea as
select *
from mywork.sample
;quit;
%mend test;
%test(name=sample);
using macro, i want to make this.
proc sql;
create table.samplea as
select *
from mywork.sample
;quit;
however, as you might expect, error statement appears in log screen. &namea wasn't converted into 'samplea'
instead, SAS recoganize '&namea' as one complete variable.
i want to make SAS recognize '&namea' as &name+a, conclusively, 'simplea'
I would really appreciate your help. thanks.
Try this:
%macro test(name=);
proc sql;
create table.&name.a as
select *
from mywork.sample
;quit;
%mend test;
%test(name=sample);
Try this:
%macro test(name=);
proc sql;
create table.&name.a as
select *
from mywork.sample
;quit;
%mend test;
%test(name=sample);
%macro test(name=); proc sql; create table &name.a as select * from mywork.sample ; quit; %mend test; %test(name=sample);
The problem seems to be that there is a syntax error in the code you are submitting (and in the code that you are trying to generate):
You submitted "create table.&namea", I think it should be "create table &namea", with a space instead of the dot.
thanks all. due to my submitting of master's graduation paper, i couldn't care less about this project.
i'm sorry for not accepting answer. due to my carelessness, maybe you all have wondered why answers were not accepted, though it was right.
thanks for all your help.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.