Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: break string into multiple variables


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: break string into multiple variables
Date   Thu, 11 Oct 2012 01:09:25 +0100

Here the -destring- makes life more difficult!

Given the original string variable

forval i = 1/13 {
             gen q`i' = real(substr(mystr, `i', 1))
}

when there are 13 characters.

Sophie needs to tell us how incomplete strings (<13 characters) are to
be interpreted. How do you know which questions were answered?

There was discussion in

SJ-3-1  pr0008   Speaking Stata: On structure & shape: the case of mult. resp.
        . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox & U. Kohler
        Q1/03   SJ 3(1):81--99                                   (no commands)
        discussion of data manipulations for multiple response data

http://www.stata-journal.com/sjpdf.html?articlenum=pr0008


On Thu, Oct 11, 2012 at 12:32 AM, Sophie Moullin
<sophiemoullin@gmail.com> wrote:
> Dear all,
>
> I've got a number of string variables which contain answers for up to
> 13 questions within the broad variable category, which when destrung
> are listed as one single numeric, e.g. 2222112222 (1 is yes, 2 is no).
> I need to create separate variables for each question 1-13.
>
> I haven't been able to find any example code for this on any of the
> stata documentation or FAQ. Any advice would be much appreciated.
>
> Many thanks,
> Sophie
> *
> *   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/
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index