08-20-2012 02:59 PM
How to use SAS searchingenginer to search a file's physical location?
For example I have a file named "abc.txt", it locates at c:\myfile .I want to know what is the physical location of the file.
Given I only know the file's name is "abc.txt" but I don't know where it is,...so how could I use searching enginer in SAS to get its location: "c:\temp"?
08-22-2012 07:38 PM
Art' code work well. But you need a little bit change since everyone's computer config is different. if you file is sitting in d: driver, please add "x d:;". The code will be like:
filename indata pipe "dir \abc.txt /b /s";
informat fil2read $255.;
infile indata truncover;
input fil2read &;
08-20-2012 03:07 PM
Are you asking to know the full path to a file that you can already find? You could use the FILENAME option on INFILE or FILE statement.
70 data _null_;
71 length filename $200;
72 infile 'myfile.txt' filename=filename;
73 putlog filename=;
NOTE: The infile 'myfile.txt' is:
Filename=C:\Documents and Settings\XXXXX\myfile.txt,
RECFM=V,LRECL=256,File Size (bytes)=0,
filename=C:\Documents and Settings\XXXXX\myfile.txt
08-20-2012 06:00 PM
The code has problem to run,
45 data _null;
46 length filename $200;
47 infile 'list.txt' filename=filename;
48 putlog filename=;
ERROR: Physical file does not exist, H:\list.txt.
08-20-2012 07:03 PM
This error indicates to me that the file list.txt is not in the current directory (root of H. From the earlier posts it is still unclear to me that the OP knows the actual location of the file.
08-23-2012 07:16 AM
In a command window (start --> run --> cmd.exe), type "help dir" and carefully read the output. Get your search working from Windows itself, then paste that code into Art's solution.
08-22-2012 06:23 PM
What happens if two files with the same name are stored in different locations, ie a new version and backed up one?
It seems one of those things that you should know where to look rather than search.
Windows Search is really useful and you can search by extension, so if i see some one has created a dataset called hidden_data I can search for it using
hidden_data ext:sas and it will list SAS programs that have that dataset in the code.
08-22-2012 06:30 PM
The code I suggested, which is basically using Window's search capabilities, will provide the full path to each file in the case of duplicate names.