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]

Re: st: Odd behaviour of wordcount function


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Odd behaviour of wordcount function
Date   Mon, 30 Jul 2012 11:45:48 -0500

-wordcount()- is subject to a limit on length of input argument. You need

. display `: word count `vars''

See -help limits- and -help extended fcn-.

Nick

On Mon, Jul 30, 2012 at 11:36 AM, Seed, Paul <[email protected]> wrote:

> I have some 20 variable names in a local macro, called "vars" , and I want
> to know exactly how many there are. Why doesn't this work?
>
> . di wordcount("`vars'")
> 12
>
> Or even this?
>
> . #delim ;
> . di wordcount("f4_latepreg_sample f4_date_late_control_visit
> f4_final_latepreg_sample f5_marital_status f5_country_of_birth
> f5_main_ethnicity f5_oth_ethnicity f5_ethnicity_custcentiles
> f5_immigration_hx f5_partcpt_migration_yrs f5_partnr_migration
> f5_yrs_schooling f5_tertiary_edu f5_oth_tertiary_edu f5_job_situation
> f5_mat_occupation f5_major_grp f5_socioeconomic_index f5_living_situation
> f5_children_in_house f5_current_accomod f5_type_accomod
> f5_partcpt_partnr_income f5_individuals_support_dollar f5_type_maternity_care")
> ;
> 12
> .#delim cp
>
> This doesn't work either, but I think I know why.
>  . di wordcount(`vars')
> invalid syntax
> r(198);
>
> I can't see this behaviour mentioned in the manuals.
> Is it a bug; or an obscure "feature", whose advantages I am blind to?
> Is there any way of stopping Stata truncating the list before counting the words,
> and why should I have to?
>
> I am using Stata version 11.2, on a Windows platform.
*
*   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