The SAS Output Delivery System and reporting techniques

How to find dataset path?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 88
Accepted Solution

How to find dataset path?

Hi,

can someone please help me on how to find dataset physical location like c:/window/... ? One more thing i just have name of the dataset neither i know library nor any program using it. ALso so i search on google there are some method like using %sysfunc and pathname function or using dictionary object or even proc dataset or proc contents will be helpfull but all it required at least library name.


is that even possible to find out dataset path without knowing library name? or is there any macro available for such issue?

Please help me. Thanks in Advanced.


Regards,

Tushar J



Accepted Solutions
Solution
‎05-30-2013 06:55 AM
Occasional Contributor
Posts: 12

Re: How to find dataset path?

Hi Tushar,

There are some files by the name VSLIB and VSTABLE in the library SASHELP. Infact, the time when we open a file a tempfile is created in these tables with the names and other credentials of the table. Please Note that WORK Library's files are hard to find the path of. This method works for any file apart from WORK Library files.

So If we know the name of the table opened we can find the path of it, using the following queries:-

%LET Data_Name=DATA_name;

proc sql noprint;

select path||"\"||"&Data_name" into Smiley Tongueath from SAShelp.Vslib where libname in (

select distinct libname from sashelp.vstable where memname="&Data_Name");

quit;

%put path= &path;

This Marco variable "path" formed can be used.

HTH,

Thanks

View solution in original post


All Replies
Trusted Advisor
Posts: 2,113

Re: How to find dataset path?

Let me see if I can rephrase this.  You know the name of a SAS dataset and you want to find out where it came from.  The answer is not necessarily unique as there might be multiple SAS datasets with the same name.  If you know the disk drive that it is on, you could write a small Windows batch file to find it and store the results in a text file that you could parse with SAS.  Something like

c:

cd \

dir foo.sas7bdat /s > findfoo.txt

It is primitive, but it would work.

Doc Muhlbaier

Duke

Frequent Contributor
Posts: 88

Re: How to find dataset path?

Hi Doc@Duke,

First of all thanks for your reply. Well Actually, i have five unix server and on one of the server the sas dataset file is located. Just for the sake understanding i have mentioned windows path for example, but i believe the way you mentioned will be helpful, i will similarly try to write shell script to run on Unix korn shell. i was just wondering if any sas program or function will be out there for such issue. Anyway the way you mentioned above i believe will work. Thanks.

Trusted Advisor
Posts: 2,113

Re: How to find dataset path?

The unix shell command is "find" for the same activity.  There is a log more filtering flexibility in unix than on windows.

Solution
‎05-30-2013 06:55 AM
Occasional Contributor
Posts: 12

Re: How to find dataset path?

Hi Tushar,

There are some files by the name VSLIB and VSTABLE in the library SASHELP. Infact, the time when we open a file a tempfile is created in these tables with the names and other credentials of the table. Please Note that WORK Library's files are hard to find the path of. This method works for any file apart from WORK Library files.

So If we know the name of the table opened we can find the path of it, using the following queries:-

%LET Data_Name=DATA_name;

proc sql noprint;

select path||"\"||"&Data_name" into Smiley Tongueath from SAShelp.Vslib where libname in (

select distinct libname from sashelp.vstable where memname="&Data_Name");

quit;

%put path= &path;

This Marco variable "path" formed can be used.

HTH,

Thanks

Frequent Contributor
Posts: 88

Re: How to find dataset path?

Hi Nishunk,

sorry for my late response, well i have tried you above code and tried to find the class dataset path which is present under sashelp library but i got below warning showing path not resolved.

7    %LET Data_Name=class;

8    proc sql noprint;

9    select path||"\"||"&Data_Name" into Smiley Tongueath from SAShelp.Vslib where libname in (

10   select distinct libname from sashelp.vstable where memname="&Data_Name");

NOTE: No rows were selected.

11   quit;

NOTE: PROCEDURE SQL used (Total process time):

      real time           0.23 seconds

      cpu time            0.26 seconds

WARNING: Apparent symbolic reference PATH not resolved.

12   %put path= &path;

path= &path

am i doing something wrong? i just replace DATA_name by class in your above code.

Frequent Contributor
Posts: 88

Re: How to find dataset path?

Hey Nishunk,

you were right actually in the code which i mentioned above i was using class but in small letter, i have changed that to capital letters and it work. Below the log i got with path,

path= &path

13   %LET Data_Name=CLASS;

14   proc sql noprint;

15   select path||"\"||"&Data_Name" into Smiley Tongueath from SAShelp.Vslib where libname in (

16   select distinct libname from sashelp.vstable where memname="&Data_Name");

17   quit;

NOTE: PROCEDURE SQL used (Total process time):

      real time           0.24 seconds

      cpu time            0.25 seconds

18   %put path= &path;

path= ( 'C:\Program Files\SAS\SASFoundation\9.2(32-bit)\nls\en\SASCFG' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\core\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\af\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\assist\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\connect\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\eis\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\ets\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\gis\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\graph\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\iml\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\insight\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\lab\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\or\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\qc\sashelp' 'C:\Program

Files\SAS\SASFoundation\9.2(32-bit)\stat\sashelp' )

                                                \CLASS

Thanks a lot, this exactly what i was looking for.

Regards,

Tushar Jagtap.

User
Posts: 1

Re: How to find dataset path?

Smiley Tongue 

Occasional Contributor
Posts: 15

Re: How to find dataset path?

Hi Nishunk,

I have one same issue like i am looking for path for a dataset. I dont know where it is located. Even I dont know the library name. Your comment will be very helpful.

Thanks,

Sunil

Occasional Contributor
Posts: 15

Re: How to find dataset path?

Actually, The above code from Nishunk it works. Thanks a lot

Sunil Jadhav

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 6363 views
  • 4 likes
  • 5 in conversation