Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Hiding contents of a do-file


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Hiding contents of a do-file
Date   Mon, 1 Feb 2010 19:46:50 -0000

In essence, when you define your Mata function the calls to local macro
`i' are dereferenced to empty strings if only because the local macro
does not exist at that point. So, the macros have no effect. 

More generally, Mata as such has no notion of Stata macros. 

I am not in your (apparently delicate) situation but I am bemused by the
effort here in hiding a fairly basic line of code. 

I am obliquely reminded of a case in which I wrote a program for a
colleague and left him with the code. He rang a couple of hours later to
say that it no longer worked. He had made four small changes, two of
which were utterly fatal. The principle for what it's worth is that
there is a big difference between looking at the code and understanding
roughly what it does and being able to make the programmer redundant. 

Nick 
n.j.cox@durham.ac.uk 

Rasika Raghavan


This would be the way I created one.mo

mata:
string scalar encode(string scalar pt)
{
return(char(ascii(pt):+1))
}

string scalar decode(string scalar et)
{
return(char(ascii(et):-1))
}

encode ("replace score = rss*coeff_rss_`i'[1] +
db_tb*coeff_db_tb_`i'[1] +remw*coeff_remw_`i'[1] +
maxp*coeff_maxp_`i'[1] +d_fifty*coeff_d_fifty_`i'[1] if overno==`i'")
mata mosave decode,replace

void one()
{
stata(decode("sfqmbdf!tdpsf!>!stt+dpfgg`stt`\2^!,!ec`uc+dpfgg`ec`uc`\2^!
,sfnx+dpfgg`sfnx`\2^!,!nbyq+dpfgg`nbyq`\2^!,e`gjguz+dpfgg`e`gjguz`\2^!jg
!pwfsop>>"))
}

mata mosave one,replace


This is the error that I am getting,

coeff_rss_ ambiguous abbreviation
                 stata():  3598  Stata returned error
                   one():     -  function returned error
                 <istmt>:     -  function returned error
r(3598);

And yes, I want the user to be just able to see the output generated
and not the way it was generated. If I send them the full do-file,
then they are free to do their own analysis, and which would leave me
redundant. Certain issues prevent me from running the do-file myself
and sending across just the output.

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index