Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: simple scripting and formulas


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: simple scripting and formulas
Date   Mon, 5 Jan 2009 22:40:29 -0000

The statement 

tempname vmin vmax 

does nothing here and could also be removed. If I were paid by the
reciprocal of the number of lines used, I wouldn't use the synonym y for
varlist but I think it makes the code a little clearer. 

Nick 
[email protected] 

Nick Cox

*! 1.0.0 NJC 5 Jan 2009 after Stas Kolenikov 
program _gstdminmax 
	version 8 
	gettoken type 0 : 0
	gettoken g    0 : 0
	gettoken eqs  0 : 0
	syntax varname [if] [in], [BY(varlist)]
	marksample touse
	tempname vmin vmax 
	local y `varlist' 
	qui bysort `touse' `by' (`y') : /// 
	g `type' `g'= (`y' - `y'[1])/(`y'[_N] -`y'[1]) if `touse'
	lab var `g' "`1' standardised to [0,1]"
end


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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