Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | drreg@earthlink.net |
To | statalist@hsphsun2.harvard.edu |
Subject | RE: st: Select the last 4 numbers out of 8... |
Date | Thu, 9 Jun 2011 13:43:02 -0400 (GMT-04:00) |
Interesting phrase "...totally vague..." Need to think about that. Or maybe not. reg jordan -----Original Message----- >From: Nick Cox <n.j.cox@durham.ac.uk> >Sent: Jun 9, 2011 11:50 AM >To: "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> >Subject: RE: st: Select the last 4 numbers out of 8... > >The question is ambiguous, meaning totally vague, about exactly what the form the data take, but whatever the details surely no special command is needed here! > >For example, if this information were in an integer variable > >gen mmdd = mod(myvar, 10000) > >and if it were in a string variable > >gen mmdd = substr(myvar, -4,.) > >would be answers to the first question, and the other answers are variations on that theme. Similar comments appear to data held as scalars or macros. > >Nick >n.j.cox@durham.ac.uk > >Jorge Eduardo Pérez Pérez > >Try the user written command -nsplit- > >ssc install nsplit > >On Thu, Jun 9, 2011 at 10:43 AM, Ivy Shiue <ivy.shiue@ki.se> wrote: > >> Does anyone know how to make a commend to only choose the last 4 numbers out of 8... for example, when we have birthdate of 8 numbers (yyyymmdd) and I only want the last 4 indicating the month and date (mmdd), how can I get it? Then do I use the same commend to extract the last 2 numbers (dd)? What if I only want the last 3rd and 4th number (mm)? > >* >* 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/ * * 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/