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

st: RE: RE: length(s) question


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: length(s) question
Date   Mon, 25 Oct 2004 22:02:05 +0100

_A_ problem ... 

Nick 
n.j.cox@durham.ac.uk 

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nick Cox
> Sent: 25 October 2004 21:59
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: length(s) question
> 
> 
> The problem is the space between your function name 
> -length- and its argument. 
> 
> The correct syntax is not 
> 
> length (s) 
> 
> but 
> 
> length(s) 
> 
> Incidentally, I don't think it follows that every 
> string should be the same length for _any_ purpose. 
> 
> In general, that would require some padding by spaces. which can 
> be very wasteful of storage. I am not clear 
> exactly what you want to do, but I've never found 
> padding by spaces essential (well, not since 
> Stata extended the range of string formats some years 
> ago), so there will be a better solution. 
> 
> Nick 
> n.j.cox@durham.ac.uk 
> 
> Julia A. Gamas
> > 
> > I am trying to determine the length of a string variable 
> > because this length
> > changes in each observation and I want to work with substr, 
> > so I need the
> > variable to be the same size accross observations.  But I'm 
> > getting an error
> > message that I simply don't understand how to fix.
> > 
> > I write:  generate long = length (vp40_11), vp40_11 is the 
> > string varible
> > whose length I want.
> > Error message reads:  "too few variables specification","r(102)"
> > However, the help section says to write
> > "generate varname = exp" and exp in this case is length (s), 
> > where "s" is
> > the string variable.
> > 
> > So I can't really understand which variable is missing.  Can 
> > anybody help me
> > out?
> 
> *
> *   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/
> 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index