Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <n.j.cox@durham.ac.uk> |
To | "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: reshape command error |
Date | Wed, 17 Nov 2010 12:52:26 +0000 |
I agree with Sergiy: The code looks fine. I guess the problem lies in the part of the data you are not showing us. Nick n.j.cox@durham.ac.uk Sergiy Radyakin Check for typos: what is fid? Assuming it is "Id" the code works (Stata 11/Windows) . clear . input Id probnum obs Id probnum obs 1. 1 1 1 2. 1 12 2 3. 1 14 3 4. 1 39 4 5. 1 40 5 6. 1 49 6 7. end . . reshape wide probnum, i(Id) j(obs) (note: j = 1 2 3 4 5 6) Data long -> wide ----------------------------------------------------------------------------- Number of obs. 6 -> 1 Number of variables 3 -> 7 j variable (6 values) obs -> (dropped) xij variables: probnum -> probnum1 probnum2 ... probnum6 ----------------------------------------------------------------------------- . end of do-file . l +----------------------------------------------------------------------+ | Id probnum1 probnum2 probnum3 probnum4 probnum5 probnum6 | |----------------------------------------------------------------------| 1. | 1 1 12 14 39 40 49 | +----------------------------------------------------------------------+ Selameab, Tehout I cannot see the problem with my reshape command. I have a dataset with multiple rows per id. Each client has unique problem types (this is a social services dataset). I want to reshape the dataset into one row per client. > > > My data looks like this: > > Id probnum obs > 1 1 1 > 1 12 2 > 1 14 3 > 1 39 4 > 1 40 5 > 1 49 6 > > My code is this: > reshape wide probnum, i(fid) j(obs) > > I keep getting the error message: problem not constant within id. > What am I missing?! * * 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/