Search code examples
cmdsaswmic

How to read Server disk space details via sas code


Here I need to read the details of my windows server disk utilization from sas code.

Below thing I want to achieve(using SAS code):
C:>wmic logicaldisk get size,freespace,caption
Caption  FreeSpace     Size
C:       42665123840   157181538304
D:       23106641920   32209104896
E:       218217590784  279169724416

With SAS, I tried using X command, but it works when we only need to command OS and doesn't care of response. Whereas in this case I want to create report/dataset out of the response coming from OS.

data _null_;
 x 'wmic logicaldisk get size,freespace,caption';
run;

Solution

  • Use the PIPE filename engine. Then you can read the output of the command as if it was a file.

    data want;
      infile 'wmic logicaldisk get size,freespace,caption' pipe firstobs=2;
      input disk $ freespace size ;
    run;