Clearing macros
Asked Answered
S

2

5

The following command removes all variables, scalars and programs that I add:

clear all 

However, global and local macros stick around.

I would like to know how to clear these out:

  • interactively from the command line and/or
  • as an opening line in my do files
Sawmill answered 23/9, 2014 at 19:59 Comment(0)
G
10

You can drop all macros with:

macro drop _all 

This is documented in help macro and the corresponding manual entry.

Gav answered 23/9, 2014 at 21:29 Comment(0)
B
3

The command below also removes some of my other global macros, which I do not want to remove:

macro drop _all

I prefer the following command, which tells you all the macros you have defined:

macro list _all

For example, x1, x2, x3, y1, y2, y3, z1, z2 and so on.

If you then just want to drop only macros y and z (but not x), then you can use this command:

capture macro drop y1 y2 y3 z1 z2

or

capture macro drop y* z*
Bookworm answered 15/5, 2019 at 0:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.