Bookmark and Share

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

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

st: Odd behaviour of wordcount function

From   "Seed, Paul" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Odd behaviour of wordcount function
Date   Mon, 30 Jul 2012 17:36:44 +0100

Dear Statalist, 

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'")

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")
.#delim cp

This doesn't work either, but I think I know why.
 . di wordcount(`vars')
invalid syntax

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.

Many thanks.

Paul T Seed, Senior Lecturer in Medical Statistics, 
Division of Women's Health, King's College London
Women's Health Academic Centre, KHP
(+44) (0) 20 7188 3642.

*   For searches and help try:

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