BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tushar
Obsidian | Level 7

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


1 ACCEPTED SOLUTION

Accepted Solutions
NishunkSaxena
Calcite | Level 5

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 :path 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

9 REPLIES 9
Doc_Duke
Rhodochrosite | Level 12

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

Tushar
Obsidian | Level 7

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.

Doc_Duke
Rhodochrosite | Level 12

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

NishunkSaxena
Calcite | Level 5

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 :path 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

Tushar
Obsidian | Level 7

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 :path 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.

Tushar
Obsidian | Level 7

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 :path 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.

Yunas
Calcite | Level 5

😛 

SunilJ
Fluorite | Level 6

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

SunilJ
Fluorite | Level 6

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

Sunil Jadhav

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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