I think I can see why I need the single quotes when I define the local `names', but why do I have to use `"`names'"' when calling the function? This makes for so many quotes everywhere, and is confusing to both read and understand. Any suggestion to make this program more refined, or maybe help me understand why the quotes work as they do when I define and call the local `names' would be very welcome. I have tried to read https://www.stata.com/manuals13/u18.pdf at "18.3.5 Double quotes" and other forum posts, but I am still confused.
Code:
clear all sysuse auto capture program drop label_variables program define label_variables version 16.1 args var_list name_list ds `var_list' local n_words : word count `name_list' forvalues i = 1/`n_words' { local _var : word `i' of `r(varlist)' local _name : word `i' of `name_list' label variable `_var' "`_name'" } end local names `""Make of Car" "Price of Car" "Mileage of Car""' label_variables make-mpg `"`names'"' describe make-mpg
0 Response to Program to label variables from list of words - How to use fewer single and double quotes
Post a Comment