Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a local variable in a grec file

    I am looking for a way to use the value of a local variable in a .grec file.

    I want to combine a series of graphs into a single one. In the resulting graph, what is now the title of each individual graph should be replaced by the year.

    This change is part of a series of changes recorded in a grec file. I would like to add this change to the grec file (or have it in a different grec file, this does not matter).

    The graph play command is called within a -foreach- loop where the year is stored in local variable X.

    I tried what seemed plausible, that is

    .subtitle.text = {}
    .subtitle.text.Arrpush `X'

    and

    .subtitle.text = {}
    .subtitle.text.Arrpush "`X'"

    These commands simply erase the title, as if the local variable was empty.

    Is there a way to do what I want to do?

    Thanks in advance.

  • #2
    Why don't you place the years in the titles of the original graphs?

    You can use gr_edit in a do-file to apply the changes recorded in a grec file. The gr_edit command is not documented.
    Code:
    sysuse auto, clear
    scatter mpg weight, subtitle("Test")
    local year = 2015
    gr_edit .subtitle.text = {"`year'"}

    Comment


    • #3
      Dear Friedrich,

      Thank you very much. This solves my problem. I did not know that you could use commands of the graph editor directly in a do file.

      The graphs were produced in a Research Data Centre and drawing them anew is not an option.

      Thanks again.

      Comment


      • #4
        Do you have the *.gph files available to you outside the RDC environment in native gph format? If so, then you can extract the data from the chart, and redraw. [Check it doesn't violate your RDC registration conditions!] Look at the tools employed by grexport (on SSC). The code doesn't always work properly for me, and I've developed hacks to get around the problems, but if you viewsource grexport.ado, you'll see the basic idea.

        Comment

        Working...
        X