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 <prakashbhu@gmail.com> 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/