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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: reshape long and variables not being found


From   Eric Booth <ebooth@ppri.tamu.edu>
To   "<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: reshape long and variables not being found
Date   Tue, 13 Jul 2010 22:24:26 +0000

<>

Are you sure your variables name prefixes (hiv & hivp) are consistent?  
Based on your description, your example works for me:

******!
clear
inp hiv2000 hiv2001 hiv2002 hiv2003 hivp2000 hivp2001 hivp2002 hivp2003
1 1 0 0 1 1 0 0
1 0 1 0 1 0 1 0
1 0 1 1  1 1 1 1
1 1 1 1 1 1 1 1 
end
g curr_id = _n
order curr_id
reshape long hiv hivp, i(curr_id) j(years)
******!



gives me the results output -->

. reshape long hiv hivp, i(curr_id) j(years)
(note: j = 2000 2001 2002 2003)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                        4   ->      16
Number of variables                   9   ->       4
j variable (4 values)                     ->   years
xij variables:
            hiv2000 hiv2001 ... hiv2003   ->   hiv
         hivp2000 hivp2001 ... hivp2003   ->   hivp
-----------------------------------------------------------------------------
r; t=0.02 17:21:33




~ Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu

>
>

On Jul 13, 2010, at 5:03 PM, Nanlesta Pilgrim wrote:

> Hello,
> 
> My data set is compose of adolescents and their parents and is
> currently in wide format.  Families are followed over 4 years.
> Therefore I have many variables with the same name for parents and
> adolescents with the suffix, "p," indicating  for parent.  For
> example, the variable for HIV status of the adolescent and parent:
> 
> hiv2000 hiv2001 hiv2002 hiv2003 hivp2000 hivp2001 hivp2002 hivp2003.
> 
> In stata my code is:
> reshape long hiv hivp, i(curr_id) j(years)
> 
> Stata returns:
> variable hivp2000 not found
> 
> Of course there are several variables in the reshape command.  If I
> simply use "hiv" and not hivp, then the dataset reshapes but my parent
> variables do not reshape.  Additionally, some parent variables are
> recognized while others are not.  Why aren't some of the parents'
> variables being recognize?
> 
> Thanks
> Nandy
> *
> *   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/


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