Date: Mon, 4 Aug 2008 05:40:31 -0700
Reply-To: "ajs2004@bigfoot.com" <ajs2004@BIGFOOT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "ajs2004@bigfoot.com" <ajs2004@BIGFOOT.COM>
Organization: http://groups.google.com
Subject: Set file time
Content-Type: text/plain; charset=ISO-8859-1
I'm trying to set file times from SAS, following this paper:
Paper 248-30
SASŪ with the Windows API
David H. Johnson, DKV-J Consultancies Ltd, UK & Australia
http://www2.sas.com/proceedings/sugi30/248-30.pdf
but it fails with:
ERROR: Read Access Violation In Task [ DATASTEP )
Exception occurred at (0202E812)
Task Traceback
Address Frame (DBGHELP API Version 4.0 rev 5)
at
rc = modulen( 'SystemTimeToFileTime', year, month, dayofwk, day, hour,
minute, seconds, mseconds, created);
(complete program is below). If I comment out that statement to check
the input values, they look ok:
Obs sasdt year month dayofwk day hour minute
seconds mseconds created
1 04AUG08:12:34:56 2008 8 2 4 12 34
56 0 .
So why doesn't it work?
By contrast, the converse function FileTimeToSystemTime works
perfectly, from
http://www.devenezia.com/downloads/sas/sascbtbl/
http://www.devenezia.com/downloads/sas/sascbtbl/file_management.sas
Using SAS 9.1.3 on Windows:
NOTE: SAS (r) 9.1 (TS1M3)
NOTE: This session is executing on the XP_PRO platform.
NOTE: SAS 9.1.3 Service Pack 4
and here's the program:
filename sascbtbl catalog 'work.win32api.win32api.source';
data _null_;
file sascbtbl;
input;
put _infile_;
cards4;
routine SystemTimeToFileTime
minarg=9
maxarg=9
stackpop=called
module=Kernel32
returns=long;
* LPSYSTEMTIME lpSystemTime // pointer to structure to receive system
time ;
arg 1 num output fdstart format=pib2.; * WORD wYear ;
arg 2 num output format=pib2.; * WORD wMonth ;
arg 3 num output format=pib2.; * WORD wDayOfWeek ;
arg 4 num output format=pib2.; * WORD wDay ;
arg 5 num output format=pib2.; * WORD wHour ;
arg 6 num output format=pib2.; * WORD wMinute ;
arg 7 num output format=pib2.; * WORD wSecond ;
arg 8 num output format=pib2.; * WORD wMilliseconds ;
* CONST FILETIME lpFileTime, // pointer to file time to convert ;
arg 9 num input format=pib8.;
;;;;
data;
sasdt = '04AUG2008:12:34:56'dt;
year = year(datepart(sasdt));
month = month(datepart(sasdt));
dayofwk = weekday(datepart(sasdt));
day = day(datepart(sasdt));
hour = hour(sasdt);
minute = minute(sasdt);
seconds = int(second(sasdt));
mseconds = 0;
created = .;
rc = modulen( 'SystemTimeToFileTime', year, month, dayofwk, day,
hour, minute, seconds, mseconds, created);
format sasdt datetime.;
run;
proc print;
run;