Smokin' With ® Pipes

Kimberly J. LeBouton, K.J.L. Computing Thomas . Rice, American Honda Motor Company, Inc.

Abstract lappllicplicp.crs.sas.data lappllicplicp.hinjosas.data lappllicplicp.pqr2.sas The FILENAME PIPE option can have your lappllicplicp.sas.camp.accord SAS® programs "smokin" in no . lappllicplicp.sas.camp.acura lappllicplicp.sas.camp.civic FILENAME PIPE allows you to read in the lappllicplicp.sas.camp.cl output of any UNIX lapplfrcplicp.sas.camp.crv lappllicplicp.sas.camp.custcont into a SAS dataset. As a SAS lapplfrc:p/icp.sas.camp.evp dataset, you now have the flexibility of the SAS lappllicplicp.sas.camp.honda lappllicplicp.sas.camp.integra language, will also down on the lappllicplicp.sas. camp. legend amount of UNIX script writing needed. Output 1 Partial Listing from Is -d Managing Data with Is Command

filename Isinfo pipe 'Is -d lappllicpl*'; Three examples will be provided to demonstrate the use of FILENAME PIPE. data_nulL; infile Isinfo pad end=last; The first example retrieves the output from the input dsn $50.; call symput('in'lIleftLn-->,trim(dsn»; UNIX Is command. The Is command displays if last then call symput(,ndsn' ,leftLn--»; a listing of dataset names. Output 1 is a partial run; list from the command Is -d /appVicpl*. The-d option shows only the directories, not the %macro mlibname; individual files associated with each directory. %do i=1 %to &ndsn; libname in&i "&&in&i"; %end; Figure 1 shows the DATA _NULL_ step that %mend; reads in the dataset names (dsn) and then stores the names in macro variables, named in1 to inn. %mlibname run; The small macro program, MUBNAME, uses proc sql; these macro variables to genemte the proper create table icp as libname statements. select * from dictionary. tables The PROC SQL creates a table of information where libname contains 'IN'; about the SAS datasets, similar to the quit; run; information provided by PROC CONTENTS. Figure 1 Program to read in Is -d

100 Filesystem 1024-blocks Free tUsed Iused tIused Mounted on /dev/hd4 32768 20436 3st 1512 10% / /dev/hd2 811008 76004 9U 24966 13% /usr /dev/hd9var 57344 30072 48'1< 2950 21% /var /dev/hd3 32768 21428 35% 239 3t /tmp /dev/hdl 57344 45520 2U 827 6% /horne /dev/lvOO 2457600 879196 65% 13042 3% /appl /dev/seilv 4325376 2746124 37% 5069 n /appl/sei /dev/lv01 U8416 51624 73% 1786 n /sappl /dev/worklv 13172736 12754768 4'1; 29 n /appl/work /dev/icplv 34177024 8689560 75% 2367 n /appl/icp /appl/icp 34177024 8689560 75'" 2367 1% /appl/icp pa04s:/web 655360 147432 78% - /amd/paD4s/web pa04s:/web 655360 147432 7st - /web

Output 2 Listing from eIf.lf

Disk Utilization with elf Command

To track the amount of disk utilization on two from the command -k. Output 2 displays the of our disks (/dev/icplv and Idev/worklv), a information provided by df -k. This data is program was written to retrieve the information captured in the DATA DF step shown in Figure 2. Figure 3 is one observation from the SAS filename df pipe 'df -1<'; filename nwork pipe 'Is -

datadf; PROC APPEND is used to save the data to a format date mmddyy8. time timeS.; permanent SAS dataset. The program is run infile df pad; input @'dev/icplv' through a cronjob on a regular basis to refresh ibl1024 ifree iperused percent. iiused; the data. input @'devlworklv' wbl1024 wfree wperused percent. wiused; njobs=&nwork; DATE: :J]6/06/97 date=today(); TIME: 9:51 time=time(); label ibl1024 ='icp 1024 blocks' IBLt024: 34177024 wbl1024 ='work 1024 blocks' IFREE: 8661132 ifree ='icp free' IPERUSED: 0.75 wfree ='work free' iperused='icp percent used' IIUSED: 2334 wperused='work percent used' ".lOBS: 15 iiused='icp iused' wiused='work iused'; WBLt024: 13172736 run; WFREE: 11984672 WPERUSED: 0.1 proc append base=worksp.master data=cIf; run; WIUSED: 296 Figure 3 OF SAS Dataset Figure 2 Program to read df-le

101 Job dahlem.872l20760.a will be run Wed Aug 20 16:46:00 PDT 1997.

Output 3 Message from at

Capturing Job # with at Command

The at command allows a user to run a UNIX command at a later time. We used it to submit '* submit batch job */ filename notify pipe SAS jobs, which would run in batch at a lower " -50 at &runtime < priority. The user could specify now or a later $HOMElbatchexecfTC_ &titlenb.sas"; time for the job to run. 1* retrieve system response */ Output 3 is the confirmation message that is data_nulL; infile notify pad; sent back to the monitor. The job number, length $100; which is in bold, can be used to status the job input info $100.; or delete the job if necessary. Once the job is call symput('mesg' ,info); processing this job number goes away, and is run; replaced by the PID. filename notify ; Figure 4 captures this message to be used later Figure 4 Program to read at command in a SAS/AF program to be displayed on the message line.

Summary

The FILENAME PIPE option allows a SAS programmer access to all operating commands output. This output turned into a SAS dataset, or a SAS macro variable, provides the user an opportunity to perform tasks usually written in UNIX. scripts.

102 References About the Authors

LeBouton, K. (1997), The Realities of Kim LeBouton is an independent consultant Downsizing: Moving a SAS@ Application with 15 years experience with SAS. Her areas from MVS@ to UN~ Proceedings of the of expertise include base SAS, SAS/STAT, Twenty Second Annual SAS® Users Group SASIFSp®, and SAS/AF software. She has a International Conference, Cary, NC: SAS BA degree in Psychology from California State Institute Inc., 658-667. University, Long Beach and a MA degree in Educational Statistics from UCLA. Kim was SAS Institute Inc. (1993), SAS Companionfor the WUSS 1997 Co-Chair. She is also a SAS UNIX Environment: Language, Version 6, Institute Quality Partner. First Edition, Cary, NC: SAS Institute Inc. Kim LeBouton Young, M.L. and Levine, J. (1995), UN~ for K..J.L. Computing Dummies~ Foster City, CA: IDO Books 3431 Yellowtail Drive Worldwide, Inc. Rossmoor, CA 90720 (562) 594-9235 email: [email protected]

Tom Rice is a Senior Systems Analyst for American Honda Motor Company. He has 8 years of experience in systems development exclusively using the SAS system. He has a BA degree in Mathematics, with an emphasis in Statistics and Computer Science, from Fort Lewis College in Durango, Colorado. He was an invited speaker to SAS Institute's "SAS Software in the Automobile Industry" seminar.

Tom Rice American Honda Motor Co., Inc. 1919 Torrance Boulevard Torrance, CA 90501-2746 (310) 783-3516 email: [email protected]

103