* Draw species-area curve program define esarea version 2.1 *** CLEAR DUMMY VARIABLES capture drop V1 capture drop V2 capture drop V3 *** DEFINE VARIABLES & STANDARD AXIS LABELS macro define _varlist "required existing " macro define _options "*" parse "%_*" parse "%_varlist", parse(" ") macro define a "l1(Cumulative Number of Species)" macro define b "b2(Number of Samples/ Relative Area Sampled)" macro define c "b1(Species-Area Curve)" *** ENTER AXIS MAXIMA generate V2=sum(%_1) di " " di "To control scale of the X-axis, enter a maximum value (must be>" _N di " OR Press to let STATA select X-axis scales." di "Enter X-axis maximum (or press )..." _r(xmax) di " " di "To control scale of the Y-axis, enter a maximum value (>" V2[_N] ")" di " OR Press to let STATA select Y-axis scales." di "Enter Y-axis maximum (or press )..." _r(ymax) *** USE DEFAULT MAXIMA, if necessary if "%xmax"=="" {macro define xmax=_N } if "%ymax"=="" {macro define ymax =V2[_N] } confirm number %xmax confirm number %ymax *** GET GRAPH TITLE di " " di "Enter a title to label this graph," di " OR press to use " in red " %_1 " in white " as a label." di "Title..." _r(label) di " " if "%label"=="" {macro define label "%_1"} macro define label "t2(%label)" *** ANCHOR X-AXIS AT 0, by adding a null observation. macro define d=_N+1 quietly { set obs %d generate V1=_n-1 generate V3=V2[_n-1] replace V3=0 if _n==1 } *** GRAPH WITH INTERACTIVES title (%label), xmax (%xmax) and ymax (%ymax) gr V3 V1, c(l) xla yla xscale(0,%xmax) yscale(0,%ymax) %a %b %c %label %_options drop V1 V2 V3 capture drop if _n==1 end