DATA Step, Macro, Functions and more

Getting error while assigning library in a macro

Accepted Solution Solved
Reply
Contributor
Posts: 71
Accepted Solution

Getting error while assigning library in a macro

[ Edited ]

 

%macro test(s_no=
,libname1 = 
,libname2 = 
,libname3 = 
,libname4 = 
);
libname inputt "&libname1";
libname interim "&libname2";
libname output "&libname3";
libname dataa "&libname4 ";
%mend test;
%test(
s_no=1234;
,libname1 = C:\Users\abc\Desktop\input; 
,libname2 = C:\Users\abc\Desktop\interim;
,libname3 = C:\Users\abc\Desktop\output;
,libname4 =C:\Users\abc\Desktop\test;
);

I am getting 
Note: Library doesn't exist error while running this code. Please let me know what am I doing wrong.


Accepted Solutions
Solution
‎08-30-2017 06:46 AM
PROC Star
Posts: 1,193

Re: Getting error while assigning library in a macro

[ Edited ]

Drop the semicolons in your arguments like this

 

%macro test(s_no=
,libname1 = 
,libname2 = 
,libname3 = 
,libname4 = 
);
libname inputt "&libname1";
libname interim "&libname2";
libname output "&libname3";
libname dataa "&libname4 ";
%mend test;
%test(
 s_no = 1234
,libname1 = C:\Users\abc\Desktop\input 
,libname2 = C:\Users\abc\Desktop\interim
,libname3 = C:\Users\abc\Desktop\output
,libname4 = C:\Users\abc\Desktop\test
);

 

View solution in original post


All Replies
Solution
‎08-30-2017 06:46 AM
PROC Star
Posts: 1,193

Re: Getting error while assigning library in a macro

[ Edited ]

Drop the semicolons in your arguments like this

 

%macro test(s_no=
,libname1 = 
,libname2 = 
,libname3 = 
,libname4 = 
);
libname inputt "&libname1";
libname interim "&libname2";
libname output "&libname3";
libname dataa "&libname4 ";
%mend test;
%test(
 s_no = 1234
,libname1 = C:\Users\abc\Desktop\input 
,libname2 = C:\Users\abc\Desktop\interim
,libname3 = C:\Users\abc\Desktop\output
,libname4 = C:\Users\abc\Desktop\test
);

 

Super User
Posts: 9,612

Re: Getting error while assigning library in a macro

Omit the semicolons after the macro parameters. Those semicolons otherwise end up as part of the directory names.

%macro test(s_no=
,libname1 = 
,libname2 = 
,libname3 = 
,libname4 = 
);
libname inputt "&libname1";
libname interim "&libname2";
libname output "&libname3";
libname dataa "&libname4";
%mend test;
%test(
s_no=1234
,libname1 = C:\Users\abc\Desktop\input
,libname2 = C:\Users\abc\Desktop\interim
,libname3 = C:\Users\abc\Desktop\output
,libname4 =C:\Users\abc\Desktop\test
);
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 155 views
  • 0 likes
  • 3 in conversation