SO, I try to figure out how to concatenate SAS Macro
the below code works
%let VARIAVLE1 =XSCUGRAD;
%macro sqlloop(maxcnt);
%do i=1 %to &maxcnt.;
%if &i = 1 %then
%do;
%let t=12345;
%let result =&&VARIAVLE&i;
%put result=&result;
%let result2=&result;
%put result2=&result2;
data dct&i;
set dct;
IF &result="A" THEN &result2="Not applicable";
RUN;
%end;
%end;
%mend;
%sqlloop(maxcnt=1)
SYMBOLGEN: Macro variable RESULT resolves to XSCUGRAD
SYMBOLGEN: Macro variable RESULT2 resolves to XSCUGRAD
then I am going to change
%let t=12345;
%let result =&&VARIAVLE&i;
%put result=&result;
%let result2=&&result&t;
%put result2=&result2;
I only changed this part, but this code did not work
%let result2=&&result&t;
The error message is
SYMBOLGEN: Macro variable RESULT resolves to XSCUGRAD
SYMBOLGEN: Macro variable RESULT2 resolves to &result12345
NOTE: Line generated by the macro variable "RESULT2".
1 &result12345
-
180
to create XSCUGRAD12345
How can/should I change???
Thanks
If you want to append a value to the of the value of a macro variable make sure you tell the macro processor where the name ends. You can do this with a period. Although I think for your situation you just have too many &'s for what you are trying to do since the & in &t should let the macro processor know where the name RESULT ends.
If your macro variables are like this:
%let result = XSCUGRAD;
%let t=12345;
Use the macro variables like this:
IF &result.="A" THEN &result.&t.="Not applicable";
or this:
IF &result="A" THEN &result&t="Not applicable";
To generate this statement.
IF XSCUGRAD="A" THEN XSCUGRAD12345="Not applicable";