Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creation date for an external file

Status
Not open for further replies.

eguva

Programmer
Jun 23, 2007
27
0
0
US
The following code is from SAS support. It isn ot working when my file name or any of the directories/sub-directories have special characters such as space or hyphen.(eg.: C:\documents settings\test.sas
Can someone help me to get away with this.The error i am getting is "Stderr output:
The system cannot find the path specified."


/**********************************************************************/
/* Samples 1 uses the DIR command to grab information about an */
/* external file on Windows. */ /**********************************************************************/


/* Sample 1: Return a file's creation date */

/* /t:c indicates you want a time field 'T', of type creation 'C' */
/* /a:-d return information for files only, not directories */


%let file=c:\tracks\dennis\x1.txt;

filename foo pipe "dir &file /t:c /a:-d ";

data _null_;
infile foo firstobs=6;

/* The ?? format modifier for error reporting suppresses printing the messages */
/* and the input lines when SAS encounters invalid data values. The automatic */
/* variable _ERROR_ is not set to 1 for the invalid observation. */


/* The & format modifier enables you to read character values that contain */
/* embedded blanks with list input and to specify a character informat. SAS */
/* reads until it encounters multiple blanks. */

input cr_date ?? :mmddyy8. cr_time ?? & time8.;
if cr_date eq . then stop;
put cr_date= worddate. / cr_time= timeampm.;
run;


 
Try this:

filename foo pipe "dir %str(%"&file%") /t:c /a:-d";

Klaz
 
Hi Klaz,

I tried this and it works.

filename foo pipe "dir %bquote("&file.") /t:c /a:-d ";

Thanks,
Eguva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top