BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tarikbirinci1
Calcite | Level 5

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.

disc_rates.png

I expect to see following sas results table:

eg_disc.png

 

Can somebody help me about this?

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

4 REPLIES 4
RichardDeVen
Barite | Level 11

-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;   
tarikbirinci1
Calcite | Level 5

Thank you very much for your invaluable response. But, rate column comes missing. What can be the reason? 

 

disc_rate_ss.png

 

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,

Tom
Super User Tom
Super User

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;
Kurt_Bremser
Super User

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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 622 views
  • 0 likes
  • 4 in conversation