Help using Base SAS procedures

Work in the current directory

Reply
Contributor
Posts: 43

Work in the current directory

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
Super Contributor
Super Contributor
Posts: 3,174

Re: Work in the current directory

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
Contributor
Posts: 43

Re: Work in the current directory

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 Smiley Tonguerogname from sashelp.vextfl
where upcase(xpath) like '%.SAS';
quit;

%put &progname;

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

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

Best regards,
JuanVte.
Trusted Advisor
Posts: 2,116

Re: Work in the current directory

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.
Respected Advisor
Posts: 3,799

Re: Work in the current directory

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.
Contributor
Posts: 43

Re: Work in the current directory

Posted in reply to data_null__
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. Smiley Sad

thank for all your comments!!
Juanvte
Ask a Question
Discussion stats
  • 5 replies
  • 137 views
  • 0 likes
  • 4 in conversation