Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: manipulate built-in stata commands


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: manipulate built-in stata commands
Date   Thu, 24 Nov 2011 15:24:35 +0100

You can use the code in official Stata .ado files. In fact, I do so
all the time when I am writing my own user written routines. What Nick
and daniel warned you against is to change the .ado files without
storing the changed version using a different name. That is in
principle not illegal, but it will probably break your installation of
Stata.

You can't directly change the code of generate as it is built in, but
you can add functionality. Say you wanted to be able to add a variable
label at the same time of generating the variable you could create a
program like the one below:

*--------------------- begin program ------------------
program define gen2
	syntax anything = exp [if] [in], [ varlab(string) ]
	
	// find the variable name
	local numtype " byte int long float double"
	local maybetype : word 1 of `anything'
	if `: list maybetype in numtype' {
		local varname : word 2 of `anything'
	}
	else if substr(`maybetype',1,3) == "str" { // you'd probably want to
change this
		local varname : word 2 of `anything'
	}
	else {
		local varname : word 1 of `anything'
	}
	gettoken varname : varname, parse(":")
	
	// generate
	generate `anything' `exp' `if' `in'
	
	// add the variable label
	label variable `varname' `"`varlab'"'
	
end
*--------------------- end program ------------------

Hope this helps,
Maarten

On Thu, Nov 24, 2011 at 1:40 PM, Jakob Pohlisch <mailjp@gmx.net> wrote:
> Hello Nick, hello daniel,
>
> sorry but it seems i haven't made myself clear. My fault. its not that i wanted to change the code and thats it. i wanted to get the code so i could make my own .ado-file. if that is illegal i'am sorry but i really didn't know that. there are so many "unoffical" .ado-files out there, that i thought i could change some of them the way i need them - for my personal use...i didn't mean to hurt someone copyrights or something like that. for sure i didn't just wanted to change the code, but wanted to change it and create my "own" .ado-file like myowngenerate.ado. too bad that this isn't possible...
>
> thanks for your help!
>
> Raoul
>
>
>
> -------- Original-Nachricht --------
>> Datum: Thu, 24 Nov 2011 12:40:44 +0100
>> Von: daniel klein <klein.daniel.81@googlemail.com>
>> An: statalist@hsphsun2.harvard.edu
>> Betreff: Re: st: manipulate built-in stata commands
>
>> Raoul,
>>
>> you are best advised not to change any of offical Stata's code, but to
>> copy that code and make changes in the copied version. You should also
>> document the changes in a .hlp file. Changing offical programs will
>> get you in trouble whenever these programs are updated and you are
>> likely to use track of what you did. Plus, it will become almost
>> impossible for others to understand your code, since you use offical
>> Stata's command names with syntax that differs for the documentation.
>>
>> This said, there is no way you can change build-in commands, since
>> these are in comiled C code.
>>
>> Best
>> Daniel
>> *
>> *   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/
>
> --
> NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
> *
> *   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/
>



-- 
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------

*
*   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   |   Site index