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;
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;