Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: wordcount() undocumented limitation?


From   Rob Ploutz-Snyder <[email protected]>
To   [email protected]
Subject   st: wordcount() undocumented limitation?
Date   Fri, 31 Aug 2012 10:04:11 -0500

Happy Friday Statalisters.

I bumped into an unexpected blip with the wordcount() function that
I'm puzzled by..  It seems to stop part-way through a long string, so
I must have hit some (undocumented?) limit of the wordcount() string
function.

It seems strange to me that the wordcount() string function shouldn't
produce the same result as the extended macro function..  maybe I'm
missing something?

Here's code to try as a do file:


#delimit ;
qui local myvarlist "ohdg altout astout ln_catout cus crp ferout
rbcfol glutoxout glutredout gpx gpxhgb hct
hemeout hep hgb feclout fenbl ldlox ntxout se sod tac transf zn wbc
gran lympout monoout cd4 cd8 tcf4
tcf8 ln_antil10 lns_antil1b ln_antil2 lns_antil4 lns_antil6 lns_antnfa
pmaifngout lns_pmail10 pmail2
lns_pmail4 pmail6 lns_pmatnfa lns_lpsifng lns_lpsil10 lpsil1b
ln_lpsil2 lns_lpsil4 lpsil6 lpstnfa lns_il2
lns_il6 lns_tnfa cd4cd8 catl culout gpxl fel sel sodlout tacl tpl znl
acet prop isobu buty isov val totfa mpo
tlr2 ln_tlr4 ln_tlr5 ln_tlr9 ln_myd ln_ikb ln_nfkb ln_tnfagene
ln_tnfaa ln_tnfab ln_tollip ln_ripk ln_tff ln_tgfb
ln_ilbgene il6gene ln_slca1 ln_slca8" ;
#delimit cr
local nY: word count("`myvarlist'") /*counts up the number of outcomes (Ys) */
noi di "This line of code  >> " as error "local nY: word count()" as
result " << counts up a total of " as error "`nY'" as result "
variables in the list"


#delimit ;
qui local myvarlist "ohdg altout astout ln_catout cus crp ferout
rbcfol glutoxout glutredout gpx gpxhgb hct
hemeout hep hgb feclout fenbl ldlox ntxout se sod tac transf zn wbc
gran lympout monoout cd4 cd8 tcf4
tcf8 ln_antil10 lns_antil1b ln_antil2 lns_antil4 lns_antil6 lns_antnfa
pmaifngout lns_pmail10 pmail2
lns_pmail4 pmail6 lns_pmatnfa lns_lpsifng lns_lpsil10 lpsil1b
ln_lpsil2 lns_lpsil4 lpsil6 lpstnfa lns_il2
lns_il6 lns_tnfa cd4cd8 catl culout gpxl fel sel sodlout tacl tpl znl
acet prop isobu buty isov val totfa mpo
tlr2 ln_tlr4 ln_tlr5 ln_tlr9 ln_myd ln_ikb ln_nfkb ln_tnfagene
ln_tnfaa ln_tnfab ln_tollip ln_ripk ln_tff ln_tgfb
ln_ilbgene il6gene ln_slca1 ln_slca8" ;
#delimit cr
local nY= wordcount("`myvarlist'") /*counts up the number of outcomes (Ys) */
noi di "But coding it this way  >> " as error "local nY= wordcount()"
as result " << only results in " as error "`nY'" as result "
variables."
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index