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: loop to insert underscore before year suffix

From   Lindsay Pettingill <>
Subject   st: loop to insert underscore before year suffix
Date   Wed, 21 Sep 2011 14:16:36 +0200

I am working with a massive panel dataset in wide form that I would
like to convert to long. The reshape command requires stubs, and I
have a ton of variables, differentiated by a variable name, followed
by the year. I'd like to generate a list of stubs, and have found some
programs here to do so, but my stubs are not separated from year with
an underscore. Instead, I just have text, followed by a number.
yearmovedinto2005 yearmovedinto2006 satisdwelling1995 satisdwelling1994
Is there a loop I can run to insert an underscore before the year, so
that I can then generate the stub names and reshape? I imagine there
is an easy way, using a wildcard, but my programming skills are close
to null.

Lindsay Pettingill
Georgetown University
*   For searches and help try:

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