03-14-2012 01:41 PM
Is there a way to check if a file is totaly transfered before start importing it?
I am transfering a file to the SAS server and I would run my infile code only when the transfer has finished.
This file has about 50 GB, i tried using this code below BUT IS NOT CORRECT BECAUSE THE FILE have_2012*.TXT is still in transfering and my table WANT WILL NOT HAVE all the records inside.
do until (fileexist("/INBOX/have_2012*.TXT"));
infile "/INBOX/have_2012*.TXT" MISSOVER DSD lrecl=32;
@0001 ANO_MVM $004.
@0005 MES_MVM $002.
@0007 COD_AGN $004.
@0011 COD_OPR $013.
@0024 ACERTO_OPR $002.
@0026 COD_CMT_OPR $002.;
thanks for any suggestion.
03-14-2012 03:44 PM
What is the server you are transfering to? Why are you starting the SAS process before the transfer has started in the first place?
03-14-2012 03:01 PM
I haven't tried it myself but how about:
I would imagine the file open would fail because it would still be locked while it is being transferred, particularly if you opened the file for update.
03-14-2012 05:28 PM
If you system and the server are running with the same (or close enough time stamps) you might be able to use the DOPEN, DOPTNUM and DINFO functions to read time stamps of the given file until it looks like the time stamps quit updating.
03-14-2012 10:16 PM
Firstly, sorry for my english I am from Brazil, sencond thanks so much for the answers.
Well, It has already transfered and I ran my process thanks.
Welll, I imagined something like, to check the file size. As I mentioned before, this file has about 50 GB, I don't know if this file is locked even when its being transfered, because I can import it but not all the records. In my machine i have windows xp and the SAS is installed in unix. Through WinSCP in windows I can follow the transfer process until its finished.
I am not sure, but maybe I could check it through unix commands (any suggestion?).
if anyone knows any way to check it, It will be greatly appreciated.
03-15-2012 12:00 AM
I haven't tried myself, but how about using some scripts (like windows batch command) to copy and paste the file and create a dummy file (like success.txt) when the transfer process is finished, so you can check the dummy file to see if the transfer is completed and if it is there start reading; else wait for a while and repeat the process.
03-15-2012 03:29 PM
Did you try the FOPEN while the file was transferring? Using the 'U' option will try to open it for update which should fail if the file is still being written.
put rc = fid = ;
If fid = 0 then you know the open failed. Also check that rc = 0 to ensure the filename function worked.
03-16-2012 05:06 AM
or maybe can use PIPE to calcualted the size of these files after very Five minutes .
If there is no change ,then use the code to import.
03-18-2012 10:41 PM
OK. Here is an example, if your site can use PIPE. I copy all the tables at a directory into WORK library.
%macro sleep_copy; %local size pre_size; %do %until(&pre_size=&size); %let pre_size=&size; filename x pipe 'dir c:\test\*.sas7bdat'; data _null_; call sleep(200); infile x dlm=' ' expandtabs end=last; input date ?? : yymmdd12. time ?? : time6. size ?? : comma32. name : $40.; total_size+size; if last then call symputx('size',total_size); run; %end; libname x v9 'c:\test'; proc copy in=x out=work memtype=data; run; %mend; %sleep_copy