SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Library assignment with macro variable in path

Reply
Occasional Contributor
Posts: 15

Library assignment with macro variable in path

Hi,

In SAS 9.3 Management console I've defined a BASE SAS library (not preassigned)  with a macro variable in the pathname: path=&dataroot\dir1\datamap.

Now I would like to open this library is SAS EG. I see the library in my list of libraries but when I open the library I get an error message:

[Error] Library TESTBEH does not exist.

If I change the path of the library to the physical location that the macro refers to then it works fine.

Does anyone know what the problem is and how it can be solved?

Thanks in advance.

Regards,

Berry

Frequent Contributor
Posts: 106

Re: Library assignment with macro variable in path

you can define this macro/libpath in your autoexec file or you can define this macro as your automatic macro variable so that every time you will open EG session it will be available for you .

Occasional Contributor
Posts: 15

Re: Library assignment with macro variable in path

Hi,

This macrovariable is already defined in an autoexec file and is available for my EG-session.

Regards,

Berry

Super User
Posts: 10,516

Re: Library assignment with macro variable in path

I don't know about the Management console but generally to get the macro value to resolve as intended you want a period after the macro variable(s).

path=&dataroot.\dir1\datamap

Respected Advisor
Posts: 3,895

Re: Library assignment with macro variable in path

It's an interesting question and one I've already tried to resolve for myself. I never managed to define a library path in metadata using a macro variable.

I believe (only believe) one of the reasons is that the path gets quoted in single quotes and you don't have a choice to change this. Considering that windows path names can contain '&' putting the path in single quotes makes kind of sense to me.

The only not so elegant solution I could come up with so far is to define the library in metadata but then to overwrite the path in the autoexec. This of course will assign the library. I have no solution of how to do this with a not pre-assigned library and leave it as not pre-assigned.

Community Manager
Posts: 486

Re: Library assignment with macro variable in path

Hello, I've cross-posted this to the SAS Macro Facility, Data Step and SAS Language Elements community in case anyone has input on this.

Anna

Ask a Question
Discussion stats
  • 5 replies
  • 1091 views
  • 6 likes
  • 5 in conversation