Newsgroups: bit.listserv.sas-l
Date:         Thu, 15 Oct 1992 21:31:14 EDT
Reply-To:     "Patrick Spreng" <76666.136@COMPUSERVE.COM>
From:         "Patrick Spreng" <76666.136@COMPUSERVE.COM>
Subject:      SAS Function

Thanks very much to Tim Dorcey, Randy Tobias, and George Jakubson!  (And to
anyone else whose response I may have missed.)  The approach that you
suggested was extremely helpful.  We don't have SAS/IML here, so I implemented
it in a SAS Data Step.  The following test appears to work:

 1                               The SAS System
                                               19:40 Thursday, October 15, 1992
 NOTE: Copyright(c) 1989 by SAS Institute Inc., Cary, NC USA.
 NOTE: SAS (r) Proprietary Software Release 6.07  TS301
       Licensed to LONE STAR GAS COMPANY.
 NOTE: Running on AMDAHL Model 5890,
                  AMDAHL Model 5890.
 NOTE: SAS system options specified are:
       SORT=4 NONEWS NOOVP LS=78 PS=45
 NOTE: The initialization phase used 0.12 CPU seconds and 916K.
 1          TITLE1 'LONE STAR GAS COMPANY';
 2          TITLE2 'TEST OF WEIGHTED NORMAL FUNCTION';
 3          TITLE3 'FOR MU = 5 AND SIGMA = 2';
 4          DATA WTEST;
 5             RETAIN MU 5 SIGMA 2 C;
 6             KEEP X W W0;
 7             IF _N_ = 1 THEN C = SIGMA/SQRT(8*ATAN(1));
 8             DO X = -1 TO 10 BY 0.25;
 9                XMU = X-MU;
 10               XMUSIGMA = XMU/SIGMA;
 11               W = XMU*PROBNORM(XMUSIGMA)+C*EXP(-0.5*XMUSIGMA*XMUSIGMA);
 12               W0 = MAX(0,XMU);
 13               OUTPUT;
 14            END;
 15         RUN;
 NOTE: The data set WORK.WTEST has 45 observations and 3 variables.
 NOTE: The DATA statement used 0.05 CPU seconds and 1247K.
 16         PROC PLOT DATA=WTEST FORMCHAR(1 2 3 5 7 9 11)='|---+--';
 17            PLOT W*X='*' W0*X='0' / OVERLAY;
 18         ENDSAS;
 NOTE: The PROCEDURE PLOT printed page 1.
 NOTE: The PROCEDURE PLOT used 0.04 CPU seconds and 1356K.
 NOTE: The SAS session used 0.22 CPU seconds and 1356K.
 NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414

                             LONE STAR GAS COMPANY                            1
                        TEST OF WEIGHTED NORMAL FUNCTION
                            FOR MU = 5 AND SIGMA = 2
                                               19:40 Thursday, October 15, 1992

                       Plot of W*X.   Symbol used is '*'.
                       Plot of W0*X.  Symbol used is '0'.

            W |
              |
         5.00 +                                                    *
         4.75 +                                                   *
         4.50 +                                                  *
         4.25 +                                                 *
         4.00 +                                                *
         3.75 +                                               *
         3.50 +                                              *
         3.25 +                                             *
         3.00 +                                            *
         2.75 +                                           *
         2.50 +                                         **
         2.25 +                                        *0
         2.00 +                                       *0
         1.75 +                                      *0
         1.50 +                                    **0
         1.25 +                                   * 0
         1.00 +                                 ** 0
         0.75 +                               **  0
         0.50 +                            ***   0
         0.25 +                       *****     0
         0.00 +        ***************0000000000
              |
              ---+---------+---------+---------+---------+---------+--
               -2.5       0.0       2.5       5.0       7.5      10.0

                                          X

 NOTE: 26 obs hidden.

Thanks, again, for your help!

Bruce Zak                       ^              CompuServe 76666,136
Lone Star Gas Company          / \             Phone (214) 573-3475
Dallas, TX                    ( + )
                               ---