BookmarkSubscribeRSS Feed
theponcer
Quartz | Level 8

I have several SAS programs from an external source that I am not sure how to interpret/modify. Each has a statement similar to the following:

 

libname out '.\sas_data_sets\output';

When I run the code, I get an error telling me that the libname is not defined. I would rather not open each file, change the libnames to what I want them to be, save, and run. Is the "." supposed to refer to some default file path? If so, how do I assign this default file path?

 

If not, I guess I can manually change. 

Thanks for the help!

 

7 REPLIES 7
PaigeMiller
Diamond | Level 26

The single dot in a Windows path name refers to the current folder, which in SAS 9.4 can be seen at the bottom left of the SAS 9.4 window, as shown here:

 

Capture.PNG

 

So your LIBNAME refers to a subfolder named \sas_data_sets\output within the current folder shown. Is that what you want?

--
Paige Miller
theponcer
Quartz | Level 8

Yep, that's what I want. Thanks for the explanation! I'm in SAS EG, so I'm not seeing the default folder pictured above. Is there a corollary for this version, or am I stuck?

 

24         proc setinit;
25         quit;

Original site validation data
Current version: 9.04.01M6P110718
Operating System:   WX64_SV .
Product expiration dates:
---Base SAS Software                                                                                    30DEC2021 (CPU A) 
---SAS/STAT                                                                                             30DEC2021 (CPU A) 
---SAS/GRAPH                                                                                            30DEC2021 (CPU A) 
---SAS Integration Technologies                                                                         30DEC2021 (CPU A) 
---SAS/Secure 168-bit                                                                                   30DEC2021 (CPU A) 
---SAS/Secure Windows                                                                                   30DEC2021 (CPU A) 
---SAS Enterprise Guide                                                                                 30DEC2021 (CPU A) 
---SAS/ACCESS Interface to PC Files                                                                     30DEC2021 (CPU A) 
---SAS/ACCESS Interface to ODBC                                                                         30DEC2021 (CPU A) 
---SAS Workspace Server for Local Access                                                                30DEC2021 (CPU A) 
---High Performance Suite                                                                               30DEC2021 (CPU A) 
---SAS Add-in for Microsoft Excel                                                                       30DEC2021 (CPU A) 
---SAS Add-in for Microsoft Outlook                                                                     30DEC2021 (CPU A) 
---SAS Add-in for Microsoft PowerPoint                                                                  30DEC2021 (CPU A) 
---SAS Add-in for Microsoft Word                                                                        30DEC2021 (CPU A) 
Tom
Super User Tom
Super User

Enterprise Guide is the problem (or really any method of running SAS that does involve calling it from the command line).   That style of indirect reference works well when you can navigate to the project directory and run your SAS code from there.

 

If you have access to run operating system commands you can use the cd command to change the current directory.

data _null_;
  infile "cd /myproject/directory" pipe;
  input;
  put _infile_;
run;
libname mydate './my_subdir';

But you might as well just set a macro variable and reference that.

%let topnode=/myproject/directory ;
libname mydate "&topnode/my_subdir";

Also note that if you are running SAS on a different machine than where Enterprise Guide is running (which is the normal reason for using Enterprise Guide) then you need to make sure the TOPNODE is actually visible from the machine where your SAS is running.

jimbarbour
Meteorite | Level 14

Can you show the exact error message?

 

One option is to set a Path macro variable in the top portion of the program and then all the other portions of the program "inherit" this value.  You set it once in the beginning of the program, and that's it.  Alternatively, you could create a parameter file or if you're executing in batch mode (as in a "production" type SAS job), you can pass the path in as a parameter.

 

Jim

 

Example:

%LET Path = x:\my_dir\my_project;

libname out "&Path\sas_data_sets\output";

 

theponcer
Quartz | Level 8

Thanks for the reply. Here's the error message: 

 

24         libname out '.\sas_data_sets\PBP';
NOTE: Library OUT does not exist.

That solution works, but then I would have to manually change each libname statement to match the below, which is what I'm trying to avoid. 

Reeza
Super User

This blog posts covers the topic, and shows you how to change the default directory. It should work in EG.

https://blogs.sas.com/content/sasdummy/2018/08/28/sas-current-directory/

jimbarbour
Meteorite | Level 14

@theponcer wrote:

Thanks for the reply. Here's the error message: 

 

24         libname out '.\sas_data_sets\PBP';
NOTE: Library OUT does not exist.

 

That is an odd message.  It's not an error per se but rather is just a note.  I think it means that whatever your current working directory is that there is no set of sub folders "sas_data_sets\PBP".  In other words, if your current working directory is "C:\Windows" there is no path "C:\Windows\sas_data_sets\PBP".  I think that's what the message means.

 

I don't know what directory you want to use, but just as an example, let's say it's X:\sastemp.  Try this snippet of code (after changing it to the directory you really want to use) before your Libname.  Make sure that subfolders "sas_data_sets\PBP" exist before you run your code.

 

%let RC = %sysfunc(dlgcdir("X:\sastemp"));
%PUT  NOTE:  &=RC;

Jim

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1159 views
  • 2 likes
  • 5 in conversation