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,
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;
-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;
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,
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;
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.