Tips:Using the PATHNAME Function

From sasCommunity

(Difference between revisions)
Jump to: navigation, search
(Tip Creation)
(moved code box)
Line 1: Line 1:
-
The PATHNAME function can be used to retrieve the physical location of a file or directory.  This can be especially useful when reassigning engines for a ''libref'' using the Macro Language.
 
-
 
<div style="float:right"><source justify='right' lang='sas'>
<div style="float:right"><source justify='right' lang='sas'>
data mydata.class;
data mydata.class;
Line 12: Line 10:
run;
run;
</source></div>
</source></div>
 +
The PATHNAME function can be used to retrieve the physical location of a file or directory.  This can be especially useful when reassigning engines for a ''libref'' using the Macro Language.
 +
Here we want to write a Version 6 copy of the data set CLASS to the same location as the MYDATA library, however in order to issue a new LIBNAME statement we need to know the location of the MYDATA library.  The PATHNAME function returns this location and the new ''libref'' (MYDAT6) can be created.
Here we want to write a Version 6 copy of the data set CLASS to the same location as the MYDATA library, however in order to issue a new LIBNAME statement we need to know the location of the MYDATA library.  The PATHNAME function returns this location and the new ''libref'' (MYDAT6) can be created.

Revision as of 18:26, 26 January 2010

data mydata.class;
set sashelp.class;
run;
 
libname mydat6 v6 "%sysfunc(pathname(mydata))";
 
data mydat6.class6;
set mydata.class;
run;

The PATHNAME function can be used to retrieve the physical location of a file or directory. This can be especially useful when reassigning engines for a libref using the Macro Language.

Here we want to write a Version 6 copy of the data set CLASS to the same location as the MYDATA library, however in order to issue a new LIBNAME statement we need to know the location of the MYDATA library. The PATHNAME function returns this location and the new libref (MYDAT6) can be created.

Submitted by Art Carpenter. Contact me at my Discussion Page.

....see also

Personal tools