Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: repeated values of a variable


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: repeated values of a variable
Date   Wed, 17 Mar 2004 12:27:18 -0000

That often used to happen. But now it is very 
easy to ensure that ados leave the data in 
the original sort order (unless of course 
it is an explicit purpose of the ado that 
the sort order will be changed). 

This is all explained clearly and concisely by Roger 
Newson in 

Newson, R. 2004. Stata tip 5: Ensuring
programs preserve dataset sort order. 
Stata Journal 4(1): 94. 

The following guidelines have been suggested 
in -stylerules- on SSC. Strictly, these are 
my style rules, and others should publish 
theirs! 

====================================
Respect for datasets 

In general, make no change to the data unless that is the 
direct purpose of your program or that is explicitly 
requested by the user.  For example,

your program should not destroy the data in memory 
unless that is essential for what it does

you should not create new permanent variables on 
the side unless notified or requested

do not use variables, matrices, scalars or global 
macros whose names might already be
in use: there is absolutely no need to guess at 
names unlikely to occur, as temporary names can 
always be used (see help on tempvar, tempname, and tempfile)

do not change the type of a variable unless requested

do not even change the sort order of data: programs 
can easily be made sortpreserve.
=================================== 

Nick 
[email protected] 

Richard Williams
> 
> In general, data sets should have id numbers; 
> sort commands 
> can be a little scary without them, and ado files may sort your data 
> without your knowledge.  It would be sort of a shame if you 
> had thousands 
> of survey questionnaires coded and then couldn't link the 
> data back to 
> their original sources.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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