The Do-File Editor - Column Mode Selection

When selecting or highlighting text in the do-file editor, the default is to select text in rows. This underlined sentence shows what I mean by this, as selecting from the beginning to the end of it shows the default mode. However, when dealing with text in the do-file editor it is often useful to be able to select a column rather than just rows. Fortunately in the do-file editor (as well as standard text editors and Microsoft Word) it is possible to select in columns. An example of this is the column below, which is underlined to show the area selected.







How to Use:

This column-select function works slightly differently depending on what operating system you are using. In all cases you select the column(s) you want by dragging across and down/up as appropriate.

  • In Microsoft Windows you hold down the Alt key

  • In Macintosh OS X you hold down the Option key

  • In Linux you hold down the Ctrl key

Worked Example:

I have a do-file containing some data on cars. I am going to give a few examples of how to use the column-select mode.

Here is the unaltered do-file:

I want to change the order of the data in the do-file. I am going to use column-select to select the “max_speed” column, and I am going to cut it out and paste it in-between the “capacity(L)” and “kpl” columns. To do this I perform the following steps:

  1. Use column-select to select the “max_speed” column

  2. Right-click selection and click “cut”

  3. Click my cursor to sit next to the “capacity(L)” heading

  4. Right-click cursor and click “paste”

This is shown in the following progression of images:

Now I am going to perform one final task. I want to identify the type of car in my dataset. All of the cars I have listed are sedans, so I am going to type this into my dataset. However, rather than typing “sedan” into each row, I am going to type it into all rows at once using column-select. To do this I perform the following steps:

  1. Put “str5 type” as the heading in the first row

  2. Use column-select to select all the rows I am going to type in together

  3. Type “sedan” which will type into all rows

This is shown in the following progression of images:

Column-select can be used for many things in the Stata do-file editor and standard text editors. Shown above are a few simple examples.

83 views0 comments

Recent Posts

See All