Hello Nick
I believe sorting by a key simply amounts to the following:-
Consider row1 and row2 of a matrix. Now sort the matrix accordiing to
row1 which is your key. and we are done! sortrows works by sorting the
ONE and only row. All I need to do is add another key row and sort by
that row.
Am I wrong ?
I am reading mark from the programming manual. I get the idea of
st_views. I do not understand what the idea behind mark is. Why is
this variable named in a funny way like __0000 ? Is this 0 / 1 in each
row depending on some criteria ? What is that criteria?
Thank you,
Ashim.
On 9/11/08, Nick Cox <[email protected]> wrote:
> Your understanding is not correct.
>
> In your example of st_view()-, -touse- contains the name of one
> variable. This is explained in the help.
>
> Nor does -marksample- produce a list of variable names. It produces a
> single variable containing 1s or 0s as appropriate. As already explained
> in my previous message, it marks observations.
>
> I continue to think your strategy here ill-advised. You would need to
> write a special Mata program or think up special Stata code for almost
> every row-wise task you envisage.
>
> Nick
> [email protected]
>
> Ashim Kapoor
>
> Hello Nick,
>
> Thank you for your time. Also thank you for your note on sortrows.
> Currently I am working on making " sortkeyrows" an ado file which will
> sort using a key. I will email the ado file to the list once I am
> done. I came across marksample while examining the code for sortrows.
>
> Let me rephrase my question.
>
> In the ado file for sortrows. we say " marksample touse".
> :
> :
> Later on we say st_view(X,., tokens(varlist), touse)
>
> Now if I understand st_view correctly touse should be a string of
> variable names which should be non zero for selection of values. But
> marksample is NOT producing is list of variable names.
>
> Where am I wrong?
>
> On 9/11/08, Nick Cox <[email protected]> wrote:
> > -marksample- is not part of Mata. It is a Stata command.
> >
> > It marks observations, not variables.
> >
> > It produces a new temporary variable, not a matrix.
> >
> > It is possible to use -marksample- independently of -syntax-:
> >
> > . sysuse auto
> > (1978 Automobile Data)
> >
> > . local if "2 == 2"
> >
> > . marksample touse, novarlist
> >
> > . su `touse'
> >
> > Variable | Obs Mean Std. Dev. Min Max
> > -------------+--------------------------------------------------------
> > __000000 | 74 1 0 1 1
> >
> > However, it is usual to use -marksample- after -syntax-, or after a
> set
> > of commands that produced similar results. I can't think up a
> different
> > kind of situation in which -marksample- is the command of choice.
> >
> > Nick
> > [email protected]
> >
> > Ashim Kapoor
> >
> > I am trying to learn MATA. I have a query. What is marksample ? Does
> > it return a matrix with 0's in place of variables which are NOT
> > marked. Is it ONLY used after syntax ?
> >
> > I did not find the help very useful. Can someone please shed some
> > light on this ?
>
> *
> * 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/