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

st: RE: question about macro


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: question about macro
Date   Tue, 9 Mar 2004 11:34:31 -0000

This is a pitfall frequently mentioned on this list, 
e.g. on 11 Dec 2003. 

Your statement 

local ind = r(levels) 

obliges Stata to evaluate the expression to the right of 
the = sign, and there is a limit on the length of expression
that can be handled, which causes truncation in this case. 

You should get where you want to be in one step by 

. levels groups, local(ind) 

Otherwise, don't evaluate where you don't need to, just copy! 

. local ind "`r(levels)'" 

avoids the evaluation. 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Shige Song
> Sent: 09 March 2004 11:22
> To: [email protected]
> Subject: st: question about macro
> 
> 
> Dear All,
> 
> I am haveing troubles with the length of macro, here is what I did
> 
> . levels(groups)
> 1111 1112 1113 1114 1115 1116 1121 1122 1123 1124 1125 1126 
> 1131 1132 1133
> 1134 1135 1136 1141 1142 1143 1
> > 144 1145 1146 1211 1212 1213 1214 1215 1216 1221 1222 1223 1224 1225
> 1226 1231 1232 1233 1234 1235 1236
> > 1241 1242 1243 1244 1245 1246 1311 1312 1313 1314 1315 1316 
> 1321 1322
> 1323 1324 1325 1326 1331 1332 1333
> >  1334 1335 1336 1341 1342 1343 1344 1345 1346 2111 2112 
> 2113 2114 2115
> 2116 2121 2122 2123 2124 2125 212
> > 6 2131 2132 2133 2134 2135 2136 2141 2142 2143 2144 2145 
> 2146 2211 2212
> 2213 2214 2215 2216 2221 2222 22
> > 23 2224 2225 2226 2231 2232 2233 2234 2235 2236 2241 2242 
> 2243 2244 2245
> 2246 2311 2312 2313 2314 2315 2
> > 316 2321 2322 2323 2324 2325 2326 2331 2332 2333 2334 2335 2336 2341
> 2342 2343 2344 2345 2346
> . local ind=r(levels)
> . display "`ind'"
> 1111 1112 1113 1114 1115 1116 1121 1122 1123 1124 1125 1126 
> 1131 1132 1133
> 1134 1135 1136 1141 1142 1143 1
> > 144 1145 1146 1211 1212 1213 1214 1215 1216 1221 1222 1223 1224 1225
> 1226 1231 1232 1233 1234 1235 1236
> > 1241 1242 1243 1244 1245 1246 131
> 
> As you can see, after extracting the contents of variable 
> "groups" and put
> the categories into a local macro "ind", more than half of 
> the content was
> truancated. Any idea about why, and more importantly, is 
> there a way to
> work around this?
> 
> I am running Stata 8.2 SE, by the way.

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