# hitcount2

How to download and try this example

    Usage: pl -gif hitcount2.htm

    Uses the data file hitcount.dat

    See also hitcount.

    Thanks to Jim Arnott for suggesting the proc transform count feature,
    the idea for this example, and for the bit of prodding on the datetime
    scale type.

    #proc getdata
    file: hitcount.dat
    // the following filter strips seconds from the time value,
    // then builds a ddMmmyyyy date and connects it with the time
    // value (separated by a dot)
    fieldnames: datetime nbytes
    filter: ##declare TIME
     	##set TIME = @@4
    	##set TIME = $substring(@@TIME,1,5)
    	@@3@@2@@6.@@TIME @@7

    // use proc transform to sum nbytes for each unique time value
    #proc transform
    action: count
    fields: datetime nbytes
    showresults: no

    #proc print
    label: After transform: nrecords=@NRECORDS nfields=@NFIELDS

    // set up plotting area with datetime in X and autorange on the y axis.
    // do x axis showing day of week and y axis
    #proc areadef
    title: Intranet web page hits
    rectangle: 1 1 6 2.5
    xscaletype: datetime ddMmmyyyy.hh:mm
    xrange: 28Sep1999.16:00 30Sep1999.12:00
    yautorange: datafield=nbytes nearest=20000
    xaxis.stubs: inc 4 hours
    xaxis.stubformat: .hhA
    yaxis.stubs: inc 50 1000
    yaxis.label: kBytes Transferred
    yaxis.labeldistance: 0.6
    frame: yes

    // do a 2nd X axis with month and day
    #proc xaxis
    stubs: inc 1 day
    stubformat: Mmmdd
    stubdetails: adjust=0,-0.15
    stubrange: 29Sep1999.00:00

    // use proc yaxis again to do grid lines at every 100 kB
    #proc yaxis
    grid: color=orange
    gridskip: min
    ticincrement: 100 1000

    // make bar graph
    #proc bars
    locfield: datetime
    lenfield: nbytes
    thinbarline: color=green