Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: reshape command error
From
Sergiy Radyakin <[email protected]>
To
[email protected]
Subject
Re: st: reshape command error
Date
Tue, 16 Nov 2010 16:52:17 -0500
Check for typos: what is fid?
Assuming it is "Id" the code works (Stata 11/Windows)
Best, Sergiy Radyakin
. 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 |
+----------------------------------------------------------------------+
On Tue, Nov 16, 2010 at 3:44 PM, Selameab, Tehout
<[email protected]> wrote:
> Hello Stata users:
>
> I'm not very experienced in STATA; trying to learn it. 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?!
>
> Many thanks,
> Tehout
>
> *
> * 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/