Thank you both for help, I knew there was a simple answer!
Thanks again,
Joanna
Nick Cox wrote:
In addition
replace ID
needs to be followed immediately by an equals sign.
In your case, your criterion seems to be that
the first three characters are "fill". If so,
the whole apparatus of wildcards, matching,
regular expressions and what have you can be
avoided by using -substr()-.
gen id2 = id
replace id2 = "filled" if substr(id,1,3) == "fill"
or even
gen id2 = cond(substr(id,1,3) == "fill", "filled", id)
Nick
[email protected]
Fred Wolfe
See this function from Stata help
strmatch(s1,s2) evaluates to 1 if s1 matches the pattern
s2; otherwise,
it returns 0.
Joanna
The new dataset contains the variable 'id' which
contains string values "fill1", "fill 2" etc and "study 1",
"study 2" etc. I have tried the following commands:
gen id2=id
replace id2 "filled" if id=="fill*"
which didn't work. I cannot find any reference of a
wildcard being used
in such a situation, is it possible? I'm sure there is a
very simple
solution to my problem so I apologise in advance!
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/