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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1419 views
  • 0 likes
  • 4 in conversation