- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Friends - i am not sure if this question appropriate in this pan or not but i wants to raise this issue i have.
We have one file coming from different stream and we use that file to process in SAS. this file has .dat extension. Sometime this file coming in with very small size and i want to know if we have a way in SAS to check file size and send out email to users...
I am using windows 2003/SAS 9.1/EG 4.1
Please help!!!
Thanks!!!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That's odd, it works for me.
Try this code with a couple of 'put' statements added for logging.
When I run it I see in the log:
rc=0
fid=1
infonum=6
data info;
length infoname infoval $60;
drop rc fid infonum i close;
rc=filename('abc', 'physical-filename');
put rc =;
fid=fopen('abc');
put fid=;
infonum=foptnum(fid);
put infonum=;
do i=1 to infonum;
infoname=foptname(fid, i);
infoval=finfo(fid, infoname);
output;
end;
close=fclose(fid);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can use system commands to check a file size and you can email users if something is wrong.
Do you have x commands enabled in your environment?
Both of these questions have answers in the forum already.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Reeza!
no, x command is not enable yet. I am in process with admin to make it enable and waiting for same. I am assuming we have to edit objectspawner.bat file with
- allowxcmd command.
but what is alternative if admin answer is no. can we still do samething?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Actually I'm not sure you need x commands, just the pipe.
Try it and let me know
The following all get filename but the dir statement can be modified to obtain size as well.
Using SAS Macro to pipe a list of filenames from a Windows directory - Stack Overflow
http://support.sas.com/resources/papers/proceedings11/179-2011.pdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If do not have the xcmd you also do not have the pipe command. That wil bring you no solution.
SAS 9.1.3 is becoming outdated the documentation at the SAS site is starting to dissapear.
You can use wildcards (*?) in filenames and create a list of your needed files in that way. SAS(R) 9.3 Companion for Windows (filename)
You will need the filevar option of the infile statement. Hmmm not finding any example I did those tricks a long time ago. Should
come up with an example.
Having the real filenames you can try the finfo fucntion (is there in 9.1.3 I believe) SAS(R) 9.3 Companion for Windows
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try this piece of code from the SAS doc'n....it works for me.
Tom
data info;
length infoname infoval $60;
drop rc fid infonum i close;
rc=filename('abc', 'physical-filename');
fid=fopen('abc');
infonum=foptnum(fid);
do i=1 to infonum;
infoname=foptname(fid, i);
infoval=finfo(fid, infoname);
output;
end;
close=fclose(fid);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks all for your information....
Thanks Tom for posting real code but when i put my values in your code without changing anything i am getting error like,
"invalid do loop control information, either initial or to expression is missing or the by expression is missing, zero or invalid"
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That's odd, it works for me.
Try this code with a couple of 'put' statements added for logging.
When I run it I see in the log:
rc=0
fid=1
infonum=6
data info;
length infoname infoval $60;
drop rc fid infonum i close;
rc=filename('abc', 'physical-filename');
put rc =;
fid=fopen('abc');
put fid=;
infonum=foptnum(fid);
put infonum=;
do i=1 to infonum;
infoname=foptname(fid, i);
infoval=finfo(fid, infoname);
output;
end;
close=fclose(fid);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
my file name is AB.WOOLAWSON.USWOO.DAT and this would be around .5 gb. sometimes it come with .2 gb which is much smaller and wants to create email alerts to users....
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You could try using a filename statement to point to the file you want to check, then use the SASHELP.VEXTFL dictionary table to extract the size information;
filename myfile 'D:\myfile.dat';
data _null_;
set sashelp.vextfl;
if fileref = "MYFILE" then do;
size_in_gb = (filesize / (1024**3));
put size_in_gb=;
end;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Tom and HJD24.
meanwhile i have used different approch,
i used proc export to get file in SAS and then used %sysfunc (open)/attrn/close options to get record and then email logic to send an email...this works fine for me...
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- HJD24 - in your code - filesize variable is uninitialized.
Thanks!