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: use of tempfile
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: use of tempfile
Date
Thu, 19 Apr 2012 12:14:39 +0100
This would be a -reshape- except for two big problems. There is no
apparent logic to why particular data end up in the same or in
different observations. Also, your first structure looks like a very
good one for most Stata problems. The second structure looks like a
disaster. In fact, the second problem is the same as the first.
For reference, I played with this. It doesn't do what you want.
clear
input item_code exp_val sales_val
6 75 .
1 100 6250
4 60 30
2 60 1
3 52 15
9 407 .
4 60 3
9 738
2 120 2
2 100 5
end
gen id = _n
reshape wide exp_val sales_val, i(id) j(item_code)
On Thu, Apr 19, 2012 at 11:53 AM, Prakash Singh <[email protected]> wrote:
> Nick,
> the data will look like this before the use of keep if command
>
> item_code exp_val sales_val
> 6 75 .
> 1 100 6250
> 4 60 30
> 2 60 1
> 3 52 15
> 9 407 .
> 4 60 3
> 9 738
> 2 120 2
> 2 100 5
>
> after using the keep if command and merging back
>
> state_code_6 exp_val_6 sales_val_6 state_code_2 exp_val_2 sales_val_2
> 6 75 . 2 60 1
> . . . 2 120 2
> . . . 2 100 5
*
* 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/