Statalist


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

st: RE: RE: RE: What is the best way to handle embedded spaces


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: What is the best way to handle embedded spaces
Date   Tue, 6 Jan 2009 20:52:26 -0000

As these appear to be values of a variable, you can get them into a
macro by using -levelsof- -- as exemplified in several recent threads.
Typing them out by hand is inefficient and error-prone. Length of
command line is then not an issue. 

Nick 
[email protected] 

Sutton, Bennett W.

This works as long as I don't insert line returns ( /* */ ) but I can
live with that.

Thank you very much! 

Nick Cox

A similar problem came up only yesterday. You need to use compound
double quotes in defining your macro. 

Sutton, Bennett W.

Seems that stata 10 is having a problem reading the first element of my
local with embedded spaces:

.                 local PrivIssuer "Finance vehicle-Priv sector
bank/finance" "Finance vehicle-Priv sector indust/util" /*
>                         */ "Private Other" "Private sector bank"
"Private sector finance" "Private sector industrial" /*
>                         */ "Private sector utility"

.                 foreach type of local PrivIssuer {
  2.                         display "`type'"
  3.                         replace issuertype2 = 1 if issuertype ==
`"`type'"'
  4.                 }
Finance
(0 real changes made)
vehicle-Priv
(0 real changes made)
sector
(0 real changes made)
bank/finance
(0 real changes made)
Finance vehicle-Priv sector indust/util
(102 real changes made)
Private Other
(3 real changes made)
Private sector bank
(1178 real changes made)
Private sector finance
(307 real changes made)
Private sector industrial
(723 real changes made)
Private sector utility
(197 real changes made)


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index