0

I'm running a code similare to the following one and the data step is not working and I can't seem to understand why

%macro macro_1(variable);
rsubmit;
data want_&variable. (keep = a b c);
set have;
run;
endrsubmit;
%mend macro_1; 


%macro testing;
%do i=1 %to 3;
%macro_1(&i.); /* My loop here*/
%end;
%mend testing;

%testing;

Here's the error I keep on getting :

Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, DATA, LAST, NULL.

I have tried using the double ampersand or using more periods at the end, unsuccessfully however

Much thanks for any help !

2
  • At which line are you getting the error? I ran your program without the rsubmit and it worked just fine. Commented Apr 1, 2022 at 11:59
  • I'm getting it at the data want&var. line of code I have no idea why Commented Apr 1, 2022 at 12:34

1 Answer 1

2

You have defined the macro variable VARIABLE on the local machine, but the code that is using the macro variable is running on the remote machine. Try pushing the value to the remote machine before trying to use it.

%macro macro_1(variable);
%syslput variable=&variable;
rsubmit;
data want_&variable. (keep = a b c);
set have;
run;
endrsubmit;
%mend macro_1; 
Sign up to request clarification or add additional context in comments.

1 Comment

Wow yes this in fact works ! I thought that I didnt need to use syslput for this macro, thinking it would "automatically" work both on the local machine and the remote machine ! Huge huge thank you !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.