Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: How to spolit variable info to multiple variables


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: How to spolit variable info to multiple variables
Date   Sun, 11 Feb 2007 16:16:50 -0000

That is an answer to a different question, as I 
understand it. (Nor is this specific question anything to 
do with -reshape-, as another answer had it.) 

A value of 145 in this example means that the individual belongs 
in categories 1, 4 and 5. Thus the use of a numeric variable
is incidental: it could also be string. 

forval i = 1/5 { 
	gen varA`i' = cond(index(string(varA), "`i'"), 1, .) 
} 

is my suggestion. 

. findit multiple responses   

turns up various material including 

FAQ     . . . . . . . . . . . . . . . . . . .  Dealing with multiple responses
        4/05    How do I deal with multiple responses?
                http://www.stata.com/support/faqs/data/multresp.html

SJ-5-1  st0082  . . . . . . . . . . . . . . . Tabulation of multiple responses
        Q1/05   SJ 5(1):92--122
        introduces new commands for the computation of one- and
        two-way tables of multiple responses

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

Nick 
n.j.cox@durham.ac.uk 

SamL
 
> Try the -tab- command.  Specifically, if I have variable 
> Married, which
> has several categories (say, 1, 2, 3, 4, and 5), I can type:
> 
> tab1 Married, generate(marx)
> 
> and that will produce 5 variables, marx1, marx2, marx3, and 
> so on, with
> marx1=1 for all cases where Married=1, and so on.

Pritpal Marjara

> > Is there any command in stata that can make separate 
> variables for multiple
> > coded responses.
> >
> > For example:
> >
> > VarA (numerical field) is coded with following responses:
> >
> > 145
> > 235
> > 1256
> > 16
> > 14
> >
> > Now I want to create six variables with the names VarA1 
> VarA2 VarA3 VarA4
> > VarA5 VarA6 and the data from VarA to be transferred/copied 
> to the newly
> > created variables (sysmis, if the variable has no code for 
> the new variable;
> > VarA2 VarA3 and  VarA6 will have missing values for first 
> row of VarA).

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index