Fax Appendix 2: Sample Code for Staging the Data

Table Of ContentsIT Service Vision Help


This is the SAS code used to stage the data from the fax log. When you want to run this code, you can submit it from the SAS PROGRAM EDITOR window or in a SAS procedure in batch/background.

Note: Do not submit it yet. Wait until you append the code, from Fax Appendix 3, for generating the definitions.

filename faxlog 'fax.log' ;

data work.faxes(drop=date time label='Fax Activity');

 attrib machine  label='Machine name'                  length=$8;
 attrib type     label='Fax Type: (S)end or (R)eceive' length=$1;
 attrib country  label='Country Code'                  length=$3;
 attrib acode    label='Area Code'                     length=$3;
 attrib phnum    label='Phone Number'                  length=$8;
 attrib pages    label='Pages Sent or Received';
 attrib timestmp label='Datetime stamp of fax' format=datetime21.2;
 attrib resent   label='Pages Resent';
 attrib connect  label='Total connect time'    format=time12.2;
 attrib pctrtry  label='Percent retries'       format=percent7.2;
 attrib status   label='Final Status Code'             length=$1;

 infile faxlog;

 input @1  machine          @10 type          @12 country
       @16 acode            @20 phnum         @29 pages
       @32 date : mmddyy8.  @41 time : time8. @50 resent
       @53 connect : time8. @62 status;

 status = upcase(status);
 if status not in('A','B','C') then do;
   put 'Invalid status code found in record ' _n_ ;
   put 'This record will not be included in the staged data';
   put machine= type= country= acode= phnum= pages= date= time=
       resent= connect= status=;
   delete;
 end;

 timestmp=dhms(date,hour(time),minute(time),second(time));

 if pages = 0 then pctrtry = .;
 else pctrtry = resent / pages ;
run;

Notes: