Bookmark and Share

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]

st: Rather blue screen than this :(


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Rather blue screen than this :(
Date   Mon, 27 May 2013 20:55:54 -0400

Just spent the whole long weekend searching for what's wrong in my
code. I love mata, but IMHO this shouldn't be happening:
*********************************************************
version 12.0
clear all
sysuse auto
keep in 1/5

mata st_view(V=.,.,"price weight length mpg")
mata min(V)
  *** some ~ 700 lines of code here
aorder
  *** another ~ 900 lines of code around here
mata min(V)
  ***      *:-o
*********************************************************
(the above code can be Ctrl+C, Ctrl+V to Stata's command line for replication)

Consulted http://www.stata-journal.com/sjpdf.html?articlenum=pr0019
and other references on views, but nowhere found any mentioning of
such behavior: seemingly innocent aorder ruins the program like a card
house. Now having the issue isolated it is clear in hindsight what's
going on (if it is still not clear, replace min(V) with V in above).
But is such behavior desirable??

Suggestions:

1) Regardless of whether the binding was done by name or by index
Stata should resolve to varname at creating the view (NOT to index as
now) and tolerate variable order changes. Or let the user decide at
creating the view whether to favor name or index.

2) Stata should destroy the view and make it unassigned when any
variable of the view is dropped. There is no way I want to use the
view to data, when I already dropped the data! (obviously there is
also a problem when instead of -aorder- above you drop one of the view
variables, e.g. mpg).

3) I have no intuition at all on what SHOULD happen to a view when a
new data file is loaded. Currently the view doesn't care, as long as
there enough variables (!) regardless of what they are (!) even
strings (!).

4) If st_view() works with numeric data only, why doesn't it issue an
error with the following?
. mata st_view(Q="A",.,"make")
. mata Q[1,1]=999
. mata Q[1,1]
  .
(above line displays a dot for missing, not 999)

Best, Sergiy Radyakin
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index