      SUBROUTINE norm(string, ipar, dset, dset_new)
c		renorms data sets
c		fwj haberl july 1988
c	implicit undefined(a-z)
      INCLUDE 'xplot.inc'
      INTEGER*4 dset, dset_new, ipar, nret, iflg, idlm
      INTEGER*4 is, ise, i, isum
      REAL*4 sum, xmin, xmax
      CHARACTER*(*) string
 
      IF (dset_new.EQ.0) THEN
         WRITE (*, '(a)') ' No data sets yet'
         RETURN
      ENDIF
      CALL xgtrl4(string, ipar, 1, 'x low', 1, xmin, nret, iflg, idlm)
      CALL xgtrl4(string, ipar, 1, 'x high', 1, xmax, nret, iflg, idlm)
      DO is = 1, dset_new
         sum = 0.
         isum = 0
         ise = dset + is
         DO i = nbins(ise), nbine(ise)
            IF (datax(i).GT.xmin .AND. datax(i).LT.xmax) THEN
               sum = sum + datay(i)
               isum = isum + 1
            ENDIF
         ENDDO
         IF (isum.EQ.0) THEN
            WRITE (*, '(a)') ' No data in selected interval'
            sum = 1.
         ELSE
            sum = sum/isum
            sum = 1./sum
         ENDIF
         DO i = nbins(ise), nbine(ise)
            datay(i) = datay(i)*sum
            erruy(i) = erruy(i)*sum
            errly(i) = errly(i)*sum
            modely(i) = modely(i)*sum
         ENDDO
      ENDDO
      RETURN
      END
