BookmarkSubscribeRSS Feed
JuanVte
Calcite | Level 5
Hi everybody!

I would like to define a SAS library in a folder inside the current folder where I am working.

For example the program Import_data.sas is located in c:\temp. This program imports some datasets and I would like to save them in c:\temp\data.

I would like to do something like we do in html

libname data '.\data';

where "." means the current directory where the program is located.

Thanks for your help!!
Juanvte
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
From the LIBNAME documentation, there is no provision for what you are asking. Your allocation effect makes no "PWD" or current drive/directory assumptions.

Scott Barry
SBBWorks, Inc.

SAS Windows Companion (example OS): LIBNAME Statement
http://support.sas.com/documentation/cdl/en/hostwin/61924/HTML/default/chloptfmain.htm
JuanVte
Calcite | Level 5
Thanks Scott,
I think that I found a solution. I adapted the syntax from
http://www.studysas.blogspot.com/2009/04/how-to-determine-executing-program-name.html

As follows:

proc sql noprint;
select scan(xpath,-1,'\') into :progname from sashelp.vextfl
where upcase(xpath) like '%.SAS';
quit;

%put &progname;

proc sql noprint;
select xpath into :progpath
from sashelp.vextfl where upcase(xpath) like '%.SAS';
quit;

%put %substr(&progpath,1,%length(&progpath)-%length(&progname)-1);

Best regards,
JuanVte.
Doc_Duke
Rhodochrosite | Level 12
For the ".\data" syntax to be supported, it has to be supported at the OS level.

Although
libname data '.\data';
may not work in Windows,
LIBNAME data './data';
does work in Unix.
data_null__
Jade | Level 19
It works in Winders too

[pre]
1 libname here '.\data';
NOTE: Libref HERE was successfully assigned as follows:
Engine: V9
Physical Name: C:\Documents and Settings\datanull\My Documents\My SAS Files\9.1\data
[/pre]

Depending on how the program is started it may not point to where you think. For me when I run my program in BATCH '.' is usually the same directory where the source program is stored.
JuanVte
Calcite | Level 5
Yes, it works but as you commented you have to define first the working directory.

In html this directory is just the directory where you execute the syntax. 😞

thank for all your comments!!
Juanvte

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 1786 views
  • 0 likes
  • 4 in conversation