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: Collapsing lines of code in a do file


From   William Buchanan <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Collapsing lines of code in a do file
Date   Mon, 2 Jul 2012 07:46:02 -0700

You could create a "master" .do file that calls several subordinate .do files.  Then each of the subordinate files would only contain the code for each of your routines:

Master.do
do data-cleaning
do descriptive_stats
do regression
do graphics
do output

It doesn't solve the collapsing issue, but it could make it easier to manage things and could give you additional flexibility with regards to updating sections of the code without affecting the rest of your file.

HTH,
Billy

Sent from my iPhone

On Jul 2, 2012, at 7:09, Tunga Kantarcı <[email protected]> wrote:

> Hello,
> 
> I have a do file which includes many lines of code. As the code
> started to get messy, I decided to classify the code in my do file
> into subsections with respect to the particular analyses I consider.
> More precisely, what I did is the following:
> 
> *-------------------------------
> * Descriptive statistics
> *-------------------------------
> {
> summarize y
> bla
> bla
> bla
> }
> *
> 
> *------------------------------
> * Regression analysis
> *------------------------------
> {
> summarize y
> bla
> bla
> bla
> }
> *
> 
> When you open and end curly brackets as I exemplified above in a do
> file, the do file editor adds a "plus sign" next to the first curly
> bracket and if you click on it the content enclosed between the
> brackets is collapsed. This gives you a way to group your long code
> into subsections so that the entire do file becomes easier to trace
> for a third party.
> 
> The problem is that when you reopen your do file, all the code is
> expanded so you need to click on the "plus sign" to collapse the code
> in the subsections again. This is very annoying as you have to do it
> every time you open the do file.
> 
> My question: Is there a way to avoid expansion of the content within
> two curly brackets when a do file is opened?
> 
> Thanks in advance,
> Tunga
> *
> *   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/


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