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]

st: Problem using wildcard and renaming string variables


From   Pierre Pratley <[email protected]>
To   statalist <[email protected]>
Subject   st: Problem using wildcard and renaming string variables
Date   Tue, 23 Jul 2013 11:23:21 -0400

Dear colleagues,

I'm having problems renaming / removing string variables using a wildcard.
I am using Stata 11.
Basically, I have added a suffix of two numbers to filenames that are in my
database as a string variable.
The two numbers identifying survey waves are: suffixes 01, 06, 09, 11 and
13 for one round 1 and
03, 05, 08, 12 or 14 for round 2.

I'm trying to create a new variable per round, one in which the suffixes
are removed for round 1, and  observations are dropped for round 2, and
vice versa.

I have gone through statalist and help functions and it seems I need to use
a -regexr extension but am having trouble with the syntax:
drop if ratingR1 regexr(ratingR1, "*[03][05][08][12][14]$")

This should drop all values in the string variable ratingR1 that end in 03,
05, 08, 12 and 14?

And then how do I replace the values 01, 06, 09, 11 and 13?

Any help would be much appreciated. Thanks.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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