Statalist


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

Re: st: Re: spliting multiple response variable


From   Svend Juul <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Re: spliting multiple response variable
Date   Thu, 10 Sep 2009 08:28:32 +0200

RAJA wrote:
 
I have a variable which is multiple response and is a string variable 
and is in character. Now, I want to know how may respondents was given 
different characters. The following is the example of the variable 
with 5 observations

     Var1
  1. ABCDE
  2. BFGH
  3. ABIJK
  4. BDJK
  5. BC
 
Now, I want to know how many are answered A, or B or C or D or E etc.
 
=========================================================
 
To put it another way: You want a separate variable for each response
/A, B, C, ...).

clear
input str5 var1
ABCDE
BFGH
ABIJK
BDJK
BC
end
 
foreach V of newlist A B C D E F G H I J K {
   gen `V' = strpos(var1,"`V'")>0
}
 
Hope this helps
Svend
________________________________________________________ 
 
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(School of Public Health, Department of Epidemiology)
Bartholins Allé 2
DK-8000 Aarhus C,  Denmark 
Phone:   +45 8693 7796 
Mobile:  +45 2634 7796
E-mail:  sj@soci.au.dk 
_________________________________________________________ 

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



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