DATA Step, Macro, Functions and more

can you reference a macro variable in libname

Reply
Occasional Contributor
Posts: 8

can you reference a macro variable in libname

Hi there,

can you make this code work?

%let dir = "C:\";
libname c &dir;
Occasional Contributor
Posts: 8

Re: can you reference a macro variable in libname

Posted in reply to siliconcreature
I mean this works under sas/windows, but not working with sas UNIX
Regular Contributor
Posts: 165

Re: can you reference a macro variable in libname

Posted in reply to siliconcreature
I haven't used UNIX in years (and never for SAS) but I thought UNIX uses the forward slash '/' for pathnames while the default in windows is the backslash( though it will accept the forward slash as valid) so try switching it in your program.
Super Contributor
Posts: 578

Re: can you reference a macro variable in libname

Posted in reply to siliconcreature
Are you perhaps trying to get your unix server based sas to see a directory on your local windows machine? I don't think that will work unless the sas server can "see" your local machine. There are some technologies that can let that happen, but the path would not be "c:\", it would be however your local drive was mounted to the unix server.
Super User
Posts: 10,023

Re: can you reference a macro variable in libname

Posted in reply to siliconcreature
How about:
[pre]
%let dir = C:\;
libname c "&dir";

[/pre]


Ksharp
Super User
Posts: 10,023

Re: can you reference a macro variable in libname

Posted in reply to siliconcreature
How about:
[pre]
%let dir = C:\;
libname c "&dir";

[/pre]


Ksharp
Occasional Contributor
Posts: 8

Re: can you reference a macro variable in libname

your way is working, thank you.
SAS Employee
Posts: 58

Re: can you reference a macro variable in libname

Posted in reply to siliconcreature
Yeah, don't use the double quotes. With the double quotes around it, the %let stores them (along with the good stuff inside) in the symbol table...

15 %let dir = "C:\";
16 %put &dir;
"C:\"
Ask a Question
Discussion stats
  • 7 replies
  • 1483 views
  • 0 likes
  • 5 in conversation