[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: unexpected "ambiguous abbreviation"

From   "Nick Cox" <>
To   <>
Subject   st: RE: unexpected "ambiguous abbreviation"
Date   Wed, 27 Feb 2008 11:07:09 -0000

On a different note, your program reminds me of -nbfit- on SSC, written
by Roberto Gutierrez and friend. 
As the friend in question, I am interested to know what you are doing
that is different. Perhaps -nbfit- 
should support it. 

Your program starts something like this. I am omitting details
irrelevant to the points I am going
to make. 

program fitnb
	version 9
	syntax [varlist] [, maxval(integer 0)]
	tokenize `varlist'
	args x 
	if `maxval' == 0 local selection "if `x' < ."
	else local selection "if `x' < . & `x' <= `maxval'"
   	sum `x' `selection'

First, it seems that you want to feed this a single variable. 

program fitnb
	version 9
	syntax varname(numeric) [, maxval(integer 0)]
	local x `varlist'
	if `maxval'==0 local selection "if `x'<."
	else local selection "if `x' < . & `x' <= `maxval'"
   	sum `x' `selection'

is then a cleaner way to start that will trap some kinds of
inappropriate input. 

Second, stipulating within your program -if `x' < .- is redundant in the
case of 
commands like -summarize- or -nbreg- which automatically omit
observations that are missing. 

What -maxval()- does, as far as your visible code is concerned, can be
done easily and directly 
if your program supports -if-. (Adding -in- does no harm either.) 

program fitnb
	version 9
	syntax varname [if] [in]

	marksample touse 
	qui count if `touse' 
	if r(N) == 0 exit 2000 

	local x `varlist'
   	sum `x' if `touse' 

Then you can call with 

fitnb foobar if foobar <= 20 

Or whatever. 


Dirk Enzmann 


*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index