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: Right to Left Column Cascade or Adjustment
From
Eric Booth <[email protected]>
To
"<[email protected]>" <[email protected]>
Subject
Re: st: Right to Left Column Cascade or Adjustment
Date
Tue, 24 May 2011 16:02:51 +0000
<>
One approach is to use -reshape-:
*************************!
clear
inp Col1 Col2 Col3 Col4 Col5
101 101 . . .
. 111 . . 333
. . . . 935
. . . 023 016
405 . . . 295 .
end
g i = _n
reshape long Col, i(i) j(N)
l
drop N
drop if mi(Col)
bys i: g N = _n
reshape wide Col, i(i) j(N)
l
**cleanup: you probably don't need this, but just to match your example data snippet:
drop i
forval n = 3/5 {
g Col`n' = .
}
l
*************************!
You could also try looping over the Cols or -xpose-ing the dataset.
- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754
On May 24, 2011, at 10:08 AM, David Torres wrote:
> There's probably a proper name for the process I'd like to carry out.
>
> Say I have five columns of information with staggard cell inputs. How do I go about moving all the information in a subsequent column back through to the first column for which no information is missing on the row?
>
> I'd like to go from something like this:
>
> Col1 Col2 Col3 Col4 Col5
>
> 101 101
> 111 333
> 935
> 023 016
> 405 295
>
>
> to something like this
>
> Col1 Col2 Col3 Col4 Col5
>
> 101 101
> 111 333
> 935
> 023 016
> 405 295
>
>
> Thanks,
> Diego
> *
> * 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/