- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody,
I am working on unix environment, so as you know with "df -h" command I can see the availability percentage of discs. But also, I need sas scripts which provide me to show disc space rate for my co-workers.
I put the unix screen as below.
I expect to see following sas results table:
Can somebody help me about this?
Thanks,
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Make sure to use colon modifier in front of the in-line informat specification in your input statement. Otherwise it reads a fixed number of characters instead of the next "word" in the line.
Once you have the percentage used you can just check if it is too high to find out which volumes are low in space.
I prefer to use the -k option (I don't care to know the size to the byte level).
data filesystems ;
infile 'df -k' pipe truncover firstobs=2;
input Filesystem :$256. size used available usedpercent :percent. MountPoint $256.;
low = usedpercent > .90 ;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
-h is human readable parameter so Size column is scale variant and will show G(igabyte) M(egabyte) K(ilobyte) T(erabyte) P(etabyte) E(xabyte) Z(ettabyte) Y(ottabyte) suffix... You can get consistent byte scale for the size using -B1.
Unix commands stdout can be read by a PIPE fileref. NOTE: Your SAS admin may have prepared a config.sas such that a session is restricted from executing external commands.
Example:
filename DF pipe "df -B1"; data systems; infile df firstobs=2; length filesystem $50 bytes used avail rate 8 mount $50; format rate percent5.; input filesystem bytes used avail rate percent. mount; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your invaluable response. But, rate column comes missing. What can be the reason?
On the other hand, I want to add a condition. I am going to devide used variable to total size variable then I want to get the percentage of the available storage. So, if the percentage of available storage less than 10%, I want to get notification through the e-mail. Is it possible to do this? Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Make sure to use colon modifier in front of the in-line informat specification in your input statement. Otherwise it reads a fixed number of characters instead of the next "word" in the line.
Once you have the percentage used you can just check if it is too high to find out which volumes are low in space.
I prefer to use the -k option (I don't care to know the size to the byte level).
data filesystems ;
infile 'df -k' pipe truncover firstobs=2;
input Filesystem :$256. size used available usedpercent :percent. MountPoint $256.;
low = usedpercent > .90 ;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the colon modifier for the PERCENT. informat:
input filesystem bytes used avail rate :percent. mount;
or assign the informat in a separate INFORMAT statement.