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

st: RE: use of expand


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: use of expand
Date   Tue, 27 Apr 2004 10:46:46 +0100

Ann Fitzmaurice
> 
> i have a data set with four variables, year ca age and n, 
> where n is the 
> number of each combination or the other three
> e.g.
> 
> yeat	ca	age	n
> 1995	1	13	309
> 1995 	1	14	420
> 1995	2	13	363
> 
> the years can range from 1995-2002, ca from 1-6 and age from 13-19
> 
> what i would like to do is to expand the data set that i have 
> one line for 
> each case so for the first line above i would have 309 
> duplicated lines
> 
> i have try using expand but it does not give me the data set 
> i want (i know 
> the total n when expanded)

. expand n 

should do this. To advise further, I think we need you to say 
precisely what you tried and in what sense it doesn't work. 

> on another point , is stata8 case sensitive , i tried the following
> tab ca - this would not work
> but
> tab CA would - if stata 8 is case sensitive is it possible to 
> turn it off

As far as I am aware, Stata has been case-sensitive since
it first appeared in 1985. There has been no change in 
its behaviour in this respect in Stata 8. 

Case-sensitivity applies in various ways. As far as Stata's 
inbuilt commands are concerned, you can't change their names. 

I guess that you want case-insensitivity to variable names, 
so that 

. tab ca 

should work on the variable -CA- whenever there is in fact no 
variable -ca-, but a variable -CA-. Presumably what you would 
also want is that 

. tab ca 

should work on the variable -ca- whenever it exists. 

In this particular case, a preprocessor program could, in 
principle, be written in the Stata language which would try out 
various possibilities for you. But you would be obliged if you wanted this 
behaviour to type something like 

. insensitive tab ca 
	
every time you wanted this. That is, there is no switch 

. set insensitive on 

or anything akin. In practice I doubt that any 
Stata programer would want to write this preprocessor, because either 
they wouldn't want to use it themselves or they couldn't 
see a way of doing this in some generality without the 
possibility of side-effects you wouldn't want. 

If your variable names are problematic, the best way 
of dealing with it is to change them. Your near neighbour 
Ada Ma started a thread yesterday on Statalist on 
changing upper case variable names to lower case. 

Nick 
[email protected] 

*
*   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