FOCUS AREAS

Statistics and Operations Research: Examples

Source Code for the Forecast Command Builder

/* Copyright(c) 2000 by SAS Institute Inc., Cary, NC USA */
/* FORCMTD.SCL:  Source code for method file.            */
/* Methods:  getarg                                      */
/* Purpose:  Extract value of a given argument from a    */
/*           forecast command string.                    */

getarg:  method

   cmd          $         /* I: FORECAST DATA= etc. */
   searchString $         /* I: arg we are looking for, e.g., VAR= */
   argLength    8         /* I: how long the string can be */
   returnString $    ;    /* O: value to return */

   pos = index( cmd, searchString );
   if pos then do;
      returnString = substr( cmd, pos+length(searchString), argLength+1 );
      pos = index(returnString, ' ' );
      if pos > 1 then
      returnString = substr( returnString, 1, pos-1 );
      end;
   else returnString = ' ';
endmethod;