DATA Step, Macro, Functions and more

Using Libname in Proc Export

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 126
Accepted Solution

Using Libname in Proc Export

I'm trying to use a Libname in a proc export and no matter what I do I get the

Apparent symbolic reference not resolved error> Any help greatly appreciated.

 

libname outy "H:\SAS Code";

 

PROC EXPORT DATA= WORK.CMFY_ProvSpecE_people

OUTFILE= "&outy.CMFY_ProvSpec_East_&date..csv"

DBMS=CSV REPLACE;

PUTNAMES=YES;

RUN;

 

Thanks,

 

Brian


Accepted Solutions
Solution
‎10-03-2016 04:40 PM
Super User
Posts: 17,963

Re: Using Libname in Proc Export

That's not how a libname is referenced. A libname is used to reference SAS datasets not paths, note the addition of the (\). 

I think you want a MACRO variable.

 

%let outy = H:\SAS Code;
 
PROC EXPORT DATA= WORK.CMFY_ProvSpecE_people
OUTFILE= "&outy.\CMFY_ProvSpec_East_&date..csv"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;

View solution in original post


All Replies
Solution
‎10-03-2016 04:40 PM
Super User
Posts: 17,963

Re: Using Libname in Proc Export

That's not how a libname is referenced. A libname is used to reference SAS datasets not paths, note the addition of the (\). 

I think you want a MACRO variable.

 

%let outy = H:\SAS Code;
 
PROC EXPORT DATA= WORK.CMFY_ProvSpecE_people
OUTFILE= "&outy.\CMFY_ProvSpec_East_&date..csv"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;
Frequent Contributor
Posts: 126

Re: Using Libname in Proc Export

Reeza,

Thanks! I keep getting mixed up on that.
Super User
Posts: 10,550

Re: Using Libname in Proc Export

It helps to show the entire code. Symbolic reference often referrs to the macro variables.

 

OUTFILE wants things in the form of an operating file system. The LIBRARY is not valid or going to be used in this case.

OUTFILE= "H:\SAS Code\CMFY_ProvSpec_East_&date..csv"

 

OR

 

%let Outy = H:\SAS Code\"; to use the way you attempted.

 

Also you would need the \ unless the folder's name is SAS CodeCMFY_ProvSpec_East_&date

Frequent Contributor
Posts: 126

Re: Using Libname in Proc Export

ballardw,

Thanks for the reply!
Super User
Posts: 5,099

Re: Using Libname in Proc Export

Your program is referring to two macro variables:  &OUTY and &DATE

 

The error message is saying that at least one of these has not been defined.  You can get a list of all user-defined macro variables with a single statement:

 

%put _user_;

 

Once  you see which are defined and which are not, you can handle this error.  There may be additional errors after that, if PROC EXPORT detects them.  But the first step is to eliminate the current error which is one (or two) of your macro variables not being defined in time.

Frequent Contributor
Posts: 126

Re: Using Libname in Proc Export

Astounding,

Thanks for the quick reply!
☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 525 views
  • 0 likes
  • 4 in conversation