Don't use long as the name of the variable that you're using. Long is a variable type, so STATA is looking for a valid variable name.
. gen long=length( district_name)
too few variables specified
r(102);
. gen str long=length( district_name)
too few variables specified
r(102);
. gen xxyy=length( district_name)
. tab xxyy
xxyy | Freq. Percent Cum.
------------+-----------------------------------
0 | 8 0.15 0.15
2 | 1 0.02 0.17
3 | 10 0.19 0.36
4 | 21 0.40 0.76
5 | 48 0.91 1.67
6 | 112 2.13 3.80
7 | 138 2.62 6.42
8 | 124 2.36 8.78
9 | 151 2.87 11.65
10 | 216 4.10 15.75
11 | 347 6.59 22.34
12 | 223 4.24 26.58
13 | 237 4.50 31.08
14 | 267 5.07 36.16
15 | 220 4.18 40.34
16 | 137 2.60 42.94
17 | 142 2.70 45.64
18 | 83 1.58 47.22
19 | 135 2.57 49.78
20 | 141 2.68 52.46
21 | 197 3.74 56.20
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Julia A. Gamas
Sent: Monday, October 25, 2004 4:48 PM
To: [email protected]
Subject: st: length(s) question
Dear all,
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?
Thanks,
Julia
Julia A. Gamas
Program on Urban, Regional and Global Air Pollution
Massachusetts Institute of Technology
77 Massachusetts Avenue 54-1823
Cambridge, MA 02139
Phone: 617-258-0230
Email: [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/
*
* 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/