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]

RE: st: Using version control software with Stata


From   Timothy Mak <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Using version control software with Stata
Date   Mon, 31 Mar 2014 16:51:51 +0800

<>
Thank you everyone for your comments. The message seems to be, if I were to use a version control software, Git or Mercurial would be the way to go. In particular, I think I would very much love to be able to attend one of Phil Schumm's courses on the use of VCS. 

Perhaps let me give a bit more details about specifically what I hope to achieve, and see if I can solicit a bit more specific advice on the subject. 

1. It seems to me what a Version Control System (VCS) does is that it automatically keeps a record of all changes to my file, numbering them sequentially, perhaps every time I save it. This record would be kept in a separate file (or files) to the current (most recent) do file. 
2. However, say I want to send the most recent do-file to someone, but I want to tag it as version 0.1.123, e.g. as part of the preamble in the do-file. I guess I won't be able to do this automatically if I use Stata's do-file editor, right? I'll still have to manually type in "* Version 0.1.123" in the first line. Or perhaps the VCS can automatically add this line to the top of the file every time it is saved, even if I just press Ctrl-S in the do-file editor?
3. Another thing is when one do-file references another. Currently my practice is to have a "V#" added to the end of the name of nearly all my do-files, e.g. "mydofileV1.do". Thus all references to do-files have to indicate the version number also. However, if I do use a VCS, where the previous versions are not stored as separate files, presumably I'll have to adopt a different system. And because the do-file editor is not really a developer's platform, I struggle to see how this can be easily done. 
4. With ado-files, I cannot even implement my system above, since if my program is -myado-, I must name it "myado.ado", and not "myadoV1.ado". Therefore, at the moment, I often write my ado-files as do files, and -run "myadoV1.do"-, before using -myado ...-. 
5. At the same time, I wonder how professional programmers cope with this problem. It is surely impractical to have names of programs/functions/modules that change with every version. Presumably, if it is a compiled language, then whenever the program is compiled, under a VCS, the version number of each of the program/function/module that is called can also be recorded. But what about scripting languages? 
6. Ideally, I'll have a system where every time I save a do-file, it will also save in its preamble the version number of all the do-files and ado-files that it refers to. Even better is that it will automatically find the appropriate version of that program/function every time I run the do file also. I know this is probably well beyond what can be practically achieved. 

Anyway, thanks for all your help. I hope this discussion is useful to many others also. 

Tim


At the moment, I keep track of multiple version of do-files by adding "V#" to the end of the file name, so e.g., I would have mydofileV1.do, mydofileV2.do, etc. But I don't always change my version number. I would normally move on to the next number if I feel I've made a big enough change to the file. I suppose what a version control software would allow me to do is to automatically save a different version every time I pressed Ctrl-S, and the many many versions of the do files would be compressed to a convenient file hidden away somewhere. (Right?) Provided space is not a problem, this seems a useful thing. However, since Stata does not come with a substantial developer interface, particularly when I have to email my do-files or dta files to other people (I tend to associate each dta file with a do file of the same name which gives the syntax for generating the dta file from some other files). 

My concern though is with referencing other do-files within do-files. Currently, in my system, I must specify the version I want to refer to. Thus if I have another do file that references "mydofile", I must either refer to "mydofileV1.do" or "mydofileV2.do". I suppose if I were to use a Version Control program, I'll still have to keep my current practice of suffixing V# to my files, if I want to refer to specific version of the do-file, although presumably the VCS can help me keep track of sub-versions. 


However, it also seems to have a drawback, which I'm not sure can be handled also by the version control software. The problem is if I want to refer 

Sometimes I give them something, and they want me to make some small changes to it. This might go back and forth a few times, and I don't want to change version number every time. Plus, if I change version number, it also means that all other do-files that depend


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jeph Herrin
Sent: 29 March 2014 04:54
To: [email protected]
Subject: Re: st: Using version control software with Stata

This may be too crude for your purposes, but I do the following. At the 
top of every do-file I put two lines

  getnow
  copy <thisdofile>.do copies/<thisdofile>.$now.do, replace

-getnow- is just a personal -ado- that stores the current date and time 
in a global -now- in an OS-friendly format (eg, 2014.MM.DD.hh.mm). Thus, 
every time a do file is run, it makes a copy of itself with a time 
stamp. This is not proper version control, but it does leave a trail of 
every do file I've ever run. <copies> is usually a local subdirectory, 
but it could obviously be set up with a global as well.

This could be extended to ado files, I'd think.

I do end up with zillions of do files, but text storage is cheap.

hth,
Jeph



On 3/28/2014 1:23 AM, Timothy Mak wrote:
> Hi Statalist,
>
> I'm beginning to accumulate quite a lot of different do files and ado for the projects I'm working on, and am thinking of using a version control software to help me keep records of my programs. However, I don't have a computer programming background, and therefore no experience of using these things, and am not even sure it's something that's useful for do and ado files. However, if anyone on the list has experience to share in this regards, I'd very much love to hear.
>
> Thanks in advance,
>
> Tim
>
> *
> *   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/
> .
>
*
*   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/

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