Graphing (Minitab)

Graph related code…

61 thoughts on “Graphing (Minitab)

  1. CLOSE ALL GRAPHS
    This keeps you from having too many graphs open during the
    execution of your macro.
    ==========================================================

      # Close all graphs using an undocumented command.  Saves time on exit.
                                
        GMAN;
          CLOSE;
            NOPrompt;
            All.

    • Thanks for your page, it’s very helpful! I did have an issue with this command though, it still prompts me to close graphs when I run it. Are there any fixes?

      GMACRO
      buffer10x
      GMAN;
      CLOSE;
      noPRompt;
      ALL.
      IMRChart ‘MFG pH (Step3s)’;
      Stamp ‘Lot’.
      xword
      GMAN;
      CLOSE;
      noPROMPT;
      ALL.
      endmacro

      • Ah, the trick is to save the graph before you try to close it – even if you don’t need to save it. For example if you have a folder on the C:\ drive this would do the trick:

        GMACRO
        buffer10x
        GMAN;
        CLOSE;
        noPRompt;
        ALL.
        IMRChart ‘MFG pH (Step3s)’;
        Stamp ‘Lot’;
        gsave “c:\mtb\tmp.jpg”;
        replace;
        jpeg.
        xword
        GMAN;
        CLOSE;
        noPROMPT;
        ALL.
        endmacro

          • You can also turn off the graph save prompt while running the macro in Tools>Options>Graphics>Graph Management>Prompt to Save a Graph Before Closing. Just remember to turn it back on if you resume to work with important graphs! I’d like to know if there is any session command that can do this inside of a macro. (Turn the save prompt on and off)

          • I don’t think you can do exactly what you want. You can close *all* open graphs with an undocumented command:

            # Use an undocumented command to close all graphs. Saves time on exit.

            GMAN;
            CLOSE;
            NOPrompt;
            All.

            You could also save the graph within the macro code to a name like “temp” so you do not get the prompt.

  2. GRAPH SAVE to JPEG FILE
    Used esp. in auto-execution macros to save graphs which get
    created. These lines would be added to the end of a graph’s
    macro commands (i.e. change the last line with a period to a
    semi-colon and add these lines).
    =============================================================

          gsave "C:\MASibley Consulting\Minitab\Macros\xxx\xx.jpg";
            replace;
            jpeg.

  3. GRAPH SAVE with BUILD FILENAME
    In this example k40 has the name of the graph to be saved.
    e.g. it might be “Machine21Performance”
    Here the GSave is part of a layout command.
    ==========================================================

     # Define File Name ; k40 has a value for the main portion of the file name
    
        Let k30 = concatenate("C:\MASibley Consulting\Minitab\Macros\",k40,".jpg")
    
      layout;
        gsave k30;
        replace;
        jpeg.

    • Hi Mark,
      I am working on a macro to put certain graphs from different worksheets into a layout, save that layout in a destination file as a JPEG (so that i can create a link to PPT) and close the layouts. I have the layout part for 4 graphs figured out but I am not quite understanding what I am supposed to do to save it to file – where to put the command and, I guess most importantly, which command to use. Here is what I have:

      Layout;
      Title “Claim Volume”.

      Worksheet “KA91”.

      IChart ‘Claim Count’;
      Stamp ‘Date’;
      Title “KA91 Claim Volume”;
      Same 2;
      HProcess ‘Stage’;
      FIGURE 0 0.5 0.5 1.

      Worksheet “IMS”.

      IChart ‘Claim Count’;
      Stamp ‘Date’;
      Title “IMS Claim Volume”;
      Same 2;
      HProcess ‘Stage’;
      FIGURE 0 0.5 0 0.5.

      Worksheet “RSW”.

      IChart ‘Claim Count’;
      Stamp ‘Date’;
      Title “RSW Claim Volume”;
      Same 2;
      HProcess ‘Stage’;
      FIGURE 0.5 1 0 0.5.

      Worksheet “Global”.

      IChart ‘Claim Count’;
      Stamp ‘Date’;
      Title “Global Claim Volume”;
      Same 2;
      HProcess ‘Stage’;
      FIGURE 0.5 1 0.5 1.

      EndLayout

      Gmanager;
      Close.

      Any help would be greatly appreciated!!!

      • Hi,

        Your solution is easy.

        After your layout command and before your title command you can add a gsave command along with its sub commands. If you look under macro snippets for graphing you can see an example.

        Cheers- Mark

        • Thanks so much! It works beautifully. Now, I have one more question, if you don’t mind. Is it possible to merge two (hopefully more) layout commands within one .mtb? I need to put in a few more graphs into layout and I want it to be done with one button click but I can’t seem to be able to figure out how to combine them so the flow goes through without any errors. Thanks again!!!

          • One layout is what will appear on window or, if printed, one page. Within that constraint you can put as many graphs as you want on the “page”, but I don’t think there is any capability to do multi-page graphing.

            I had a similar need and used a batch command file and a separate program to do an after the fact join of separate JPEG files into one PDF file. I can’t remember the name of the utility but I’m sure similar ones still exist.

            Cheers – Mark

  4. LAST UPDATED SUBTITLE
    This code allows you to create a “Last Updated: 2012-02-12” style
    sub-title
    =================================================================

      # Create the sub-title
      
        let C199 = now()               # C199 is an empty column
        date C199 C199;                # The now() function returns time as a number; 
          format(dt yyyy-mm-dd hh:mm). #   convert to date in international format
        text C199 C199                 # Convert the date to a text string
        Let k1 = CONCATENATE("Last Updated: " ,C199)
        erase C199                     # Erase no longer needed column

  5. Hi

    I would like to edit the background color and other display properties of the graph using Macro. Can you help me out with the commands.

    • The basic approach is to:

      – generate your graph
      – edit it interactively to have the colours, etc that you want
      – then capture the macro commands by clicking on the graph to give it “focus” and then EDITOR > COPY COMMAND LANGUAGE.
      – switch to the macro you are creating and paste the commands

      See the items on this web site:

      – How To > Layout – 2 Plots Overlaid
      – How To > Scatter Plot with Error Bars

      for worked examples.

      Let me know if you need more help.

      • Awesome.. That really helped. But I have multiple graphs in my Macro . Is there a way to use the property commands one single time for all the graphs?

        sample of my code:


        ..

        IChart ‘Planned’;
        Stamp ‘Week’;
        HProcess ‘Month’.
        IChart ‘Actual’;
        Stamp ‘Week’;
        HProcess ‘Month’.
        IChart ‘Under I’;
        Stamp ‘Week’;
        HProcess ‘Month’;
        Session;
        Graph;
        Type 1;
        Color 0;
        Connect;
        Symbol;
        OutLabels;
        Title;
        Footnote;
        FPanel;
        NoDTitle.
        ..
        ..

  6. Hi,

    I’ve been following your forum and it has helped me a lot.

    I would like to know if it is possible to append information (constants, variables, columns contents) to the report. Some type of accessory information after a graph in the report.

    Thank you.

    • I haven’t used the Report function much but here are some things you can do:

      –> you can highlight lines from the session window, right click and then choose: Append Selected Lines to the Report
      –> you can take a screen shot (say with the Windows Snipping Tool) and paste it into the report

      Given this you can:

      –> use the info command to get information on variables and constants (if you have the command language prompt turned on).
      –> highlight all (or a portion) of the worksheet, Press Ctrl/C to Copy and then Paste (Ctrl/V) at the appropriate spot in the report. The only problem is that column names are often longer than the allowed width between tab stops and so they may not show up over the right column.

      I hope this helps – Mark

  7. How we can select a sepcific graph on the screen and add reference line to it ?
    I tryed this but reference lines added to both graphs.
    Is there any special command to select just a graph from the group ?

    MTB> IMRChart C6;
    SUBS> Reference 2 90 100.

    Thanks in advance,

    • Alas, there is no ability to selectively add reference lines to just the Individuals Control Chart (or the Moving Average Control Chart). You can generate the graph using the session commands shown above and then interactively click on the undesired reference line and press .

      If you want an approach that will work with macro code only (i.e. no after the fact manipulations), you could generate the Individuals and the Moving Average Control charts separately and use the layout command to position the graphs in the top and bottom halves of the figure region so that it looks like a conventionally generated I-MR chart.

      The resulting session commands (for my column of interest “Y” and reference lines of 79 and 81) would be:


      Layout.

      IChart Y;
      Figure 0 1 0.5 1;
      Reference 2 79 81.

      MRChart Y;
      Figure 0 1 0 0.5;
      NoDTitle.

      EndLayout

      • Dear Mark,
        Codes successfully executed in command line.
        But when I insert codes in executable mtb file, I am getting this error: >>Unknown Minitab command: Ï<<
        Layout command not executed. Is this a bug?

        Layout.
        IChart C6;
        Reference 2 90 101;
        FIGURE 0 1 0,5 1.
        MRChart C6;
        NoDTitle;
        FIGURE 0 1 0 0,5.
        EndLayout

        • Naci,

          There is some garbling of your error message.

          The usual reason for this error is misplacement of semicolons or periods. Does your previous command follow the structure of:

          main command;
          sub command;

          last subcommand.

          ??

          i.e. semicolons until the last sub-command which would end with a period.

          Note: if you have a single line command without subcommands you can end it with a period or leave the period off. e.g. in the above code

          layout

          or

          layout.

          are equally valid.

          I copied and pasted your code and ran it without an error – however being in North America I changed the 0,5 to 0.5 as on this side of the pond we use the period as our decimal separator.

          • Hi Mark,
            Problem was mtb file format which was created using Notepad++ as “UTF-8 with Bom”. Pure ASCII file format solved my strange problem.
            Once again, thank you so much for your great effort to share your knowledge.

  8. Hello,
    I am trying to write into my macro color changes to graphs so they print out with the colors. Such as the data points on a scatter plot are green. Do you know if this is possible or do I have to change it once the graph is already produced?
    Thank you

  9. Maestro,

    Do you know if there is a way to output ReportPad graphs to an RTF using a GSAVE? I currently have the code below working, but I would like to save it in RTF for easy access in word. So far Minitab doesn’t like the subcommand RTF.

    Do k5=1:k4
    let k6 = concatenate(“U:\SPC Charts\”,TRIM(‘CLIENT_LIST'[k5]),”.jpg”)
    LAYOUT;
    GSAVE k6;
    replace;
    JPEG.

    IChart ‘QUALIFIED’;
    Stamp ‘RUN_DT’;
    Title “X-Bar Chart”;
    Include;
    Where “WHEN(‘CLIENT_CD’ = ‘CLIENT_LIST'[k5])”;
    Test 1 2 3 4 5 6 7 8;
    DefTest 1 1.75.
    ENDLAYOUT.

    GMANAGER;
    CLOSE;
    noprompt.

    ENDDO

    • Alas, as far as I know there are no session commands to interact with ReportPad. What I have done is save graphs in JPEG format. If I need to access more than one graph or report, a simple option is to create a word document with links to the files in question and then save the word document as an web page.

      Does anyone have a better solution?

  10. Hi,
    Just found your site and I figured you may be able to help me. I’m new to making macros in minitab and I’m trying to add a reference line to an Xbar-R chart. But if I add it as a sub command for the XRChart then it automatically plots the line on both the xchart of the averages and ranges, I just want it on the average reference line plotted. So how do I do this, can you make a macro that calls the graph and deletes or adds a reference line after the fact. I tried to use the Model subcommand for the reference line but that didn’t work. Any ideas? Thanks

    • I’ve had this exact issue. Steps:

      1. Start a graph layout (see elsewhere on the site for an example).

      2. In the top half of the layout plot an X-Bar chart with your reference line.

      3. In the bottom half plot a range chart.

      4. End the layout.

      Voila!

  11. Hi Maestro,

    I am working on a macro which calculates the Cpk of multivariables. In this macro I would want to have commands to save the Cpk value in minitab cell and the graph generated through Capability analysis of Normal data for multiple variables( MCAPA) in a folder.

    I am trying to use below save command( Cpk C20 and gsave) which are working in case of capability analysis of single variable.

    “cpk c20
    GSAVE “C:\Users\ABC\Documents\Minitab macro\Minitab macro2″;

    JPEG.”

    However when I add same commands in my MCAPA commands I am getting an error “GSAV is out of sequence or is not valid with this command”

    The commands I am using for Multivariable is below

    “MCapa ‘Yield’ ‘Yield1’;

    Size 1;

    LSpec 50;

    USpec 55;

    GHISTOGRAM;

    CStat;

    Cpk c20;

    GSAVE “C:\Users\abc\Documents\Minitab macro”;

    JPEG.”

    Could you help by providing the right command for this in Mcapa so that I can incorporate in my macro.

    Looking forward for a reply.

    Thanks,

    Jatin Katara

  12. Hello,

    I am trying to create Laney P charts. In doing so, some of the data is faulty. Is there a way to exclude datapoints where the dividend > divsor? If not, a way to skip to the next graph on error? Thanks for your time.

    GMACRO
    ChartMacro

    PPrimeChart ‘Matched’ ‘Source_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘Updates’ ‘Delta_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘Adds’ ‘Delta_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘Delta_Count’ ‘Source_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘Loaded_to_Staging’ ‘Reformat_Input’;
    Stamp ‘DATE’.
    PPrimeChart ‘Spanned_Records’ ‘Reformat_Input’;
    Stamp ‘DATE’.
    PPrimeChart ‘Total_Imputed’ ‘Reformat_Input’;
    Stamp ‘DATE’.
    PPrimeChart ‘Accepted’ ‘Initial_Staging_Load’;
    Stamp ‘DATE’.
    PPrimeChart ‘Rejected’ ‘Initial_Staging_Load’;
    Stamp ‘DATE’.
    PPrimeChart ‘Added_from_Batch’ ‘Delta_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘Updated_from_Batch’ ‘Delta_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘Deleted_from_Batch’ ‘Delta_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘New_Actives’ ‘Accepted’;
    Stamp ‘DATE’.
    PPrimeChart ‘New_Terms’ ‘Accepted’;
    Stamp ‘DATE’.
    PPrimeChart ‘Net_New_Records’ ‘Added_from_Batch’;
    Stamp ‘DATE’.
    IMRChart ‘Major_Medical_Staging’;
    Stamp ‘DATE’.
    RunChart;
    RSub ‘Records_in_NEDB’.
    RunChart;
    RSub ‘Exported_to_MF_3’.

    XWORD

  13. Hello,

    I am trying to create Laney P charts. In doing so, some of the data is faulty. Is there a way to exclude datapoints where the dividend > divsor? If not, a way to skip to the next graph on error? Thanks for your time.

    GMACRO
    ChartMacro

    PPrimeChart ‘Matched’ ‘Source_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘Updates’ ‘Delta_Count’;
    Stamp ‘DATE’.
    PPrimeChart ‘Adds’ ‘Delta_Count’;
    Stamp ‘DATE’.

    XWORD

  14. Sorry for the delay in replying. I had a great holiday!

    I’d suggest you create a modified variable where you make it a missing data point if it is faulty. e.g. use the calculator function to create a new variable “MatchedClean” and set it to a value of:

    If(‘Matched’<'Source_Count'),'Matched','*') Then when you chart 'MatchedClean' vs 'Source_Count' you will not get an error but you will get a gap in the chart to remind you that there was faulty data.

    • How do I write the calculator function? I tried what you said but it didn’t work

      MTB > Name C45 ‘Matched Clean’
      MTB > Let ‘Matched Clean’ = IF(‘Matched'<'Source_Count'),'Matched','*')
      Let 'Matched Clean' = IF('Matched'<'Source_Count'),'Matched','*')
      X
      * ERROR * Unexpected symbol at X
      * ERROR * Completion of computation impossible.

      • Also is there a possible way to skip on error? I would really prefer to do it that way. Thanks!

        • I don’t have Minitab at my disposal right now but you could try the statement

          Plug

          And see if that helps.

      • My mistake.

        There should only be one right bracket at the end of the expression- not the one in the middle.

  15. Hi there,

    I hope you can help me.

    I have the following code to create and save a graph but am getting the error “Extra Text is not allowed”. Really not sure what I’ve done wrong. I know the graph creation area is fine, but it seems to stumble at the save part.

    GMACRO
    ControlChart

    ECHO

    IMRCHART ‘KG5’;
    STAMP C1;
    Display 25;

    GSAVE “C:\AutoImporter\Chart”

    NOECHO

    ENDMACRO

    • Apologies. After deleting the lines and then re-entering them this seems to have fixed itself. Still don’t know what was wrong initially, but there you go.

      Thanks for the very helpful page you have 🙂

  16. Hello,
    I want to generate several boxplots within a gmacro. Is it possible to refer to the specific value of a categorial variable from within the macro. Let’s say:

    Boxplot ( ‘CTR’ ) * ‘RepMon’;
    Group ‘Something’;
    IQRBox ‘Something’;
    Outlier ‘Something’;
    Separate ‘myCategory’;

    assuming myCategory has values ‘A’, ‘B’ and ‘C’. Is it possible to get the specific value during boxplot generation, i.e. I could concatenate a Standard string with the specific value of myCategory to “FilenameA”, “FilenameB”, …

    Thanks
    Paul

    • I wasn’t ready to publish it yet as it is a work in progress but if you check under Modules > MTB 06 Advanced Minitab Macros I think you’ll see what you need to know to do exactly what you are looking for.

      Enjoy – Mark

  17. Hi all,
    I’m trying to automate the creation of histograms, grouped in panels. so far it ‘s easy, but I would like to know if there is any command to organize the panels as you want. In my case I want them organized in rows, one graph above the next, but minitab orders the in a matrix arrangement (2×2, 3×3, etc) (I can do it with a right click in the graph after it’s generated, but no code is generated in history)
    Do you know if there is a way to do it?

    thanks

    • I’m on the road without a computer but if memory serves me right if you edit your graph to have 1 column and n rows, then if you click on

      Editor > Capture Command Language

      It should add the needed Panel commands when it copies the commands into the clipboard.

      If that doesn’t work then you are into creating a graph Layout (described elsewhere on this site). You could create your unique panels with a histogram which has Include / Where commands.

      Let me know if you need more guidance.

      Mark

  18. Hi,

    I was trying to create macro for Pie chart. However I tried to insert title in the macro, but title did not change. I am not sure where I am making a mistake.. Please help..

    Thanks
    Mohan R

  19. Sorry I missed to include code… Here it is.

    GMACRO
    VoteComparison
    PieChart ‘xyz Q8 Opinion 2018’;
    Increasing;
    Combine 0.02;
    SLabel;
    Percent;
    PLine;
    Panel ‘xyz Q11 Actual 2013’;
    VFirst.
    Title “Vote Comparison Between 2013 and 2018”

    ENDMACRO

    • Mohan,

      In Minitab commands can have subcommands on lines that end with a semi-colon. The final subcommand must end with a period.

      For your pie chart you have ended the command with the VFirst subcommand line — note the period.

      Your title command is a stand alone command not connected with the pie chart. Here is the corrected code:

      GMACRO
      VoteComparison

      PieChart ‘xyz Q8 Opinion 2018’;
      Title “Vote Comparison Between 2013 and 2018”;
      Increasing;
      Combine 0.02;
      SLabel;
      Percent;
      PLine;
      Panel ‘xyz Q11 Actual 2013’;
      VFirst.

      ENDMACRO

      Cheers – Mark

  20. Hi Mark, I’m having some problems with a macro that appears to be easy.
    I’m using minitab 17 and I’m trying to create some Individual Value Plot (IVP) to attach to a technical report, but the problem is that we want an special IVP, we want an XIndplot (this is the command name) that is a IVP that contains a little table in the right side with the descriptive statistics, the idea is create this graphs (4 graphs) and slot all of those in the folder “C:\Minitab_Project_Report\”, the problem is that this kind of graph doesn’t allow the GSAVE command and throws an error.

    However, another option is with a XWORD command, the command line allows me to create a word document with the graphs, but what I want is to attach it to a document already in existence, and the other problem making this is that the XIndplot creates 3 different “graphs” and I just want the last one. So, I will show you my code below.

    GMACRO
    STARTUP

    WOPEN “C:\Minitab_Project_Report\Histovariab.xls”;
    FTYPE;
    EXCEL;
    DATA;
    IGNOREBLANKROWS;
    EQUALCOLUMNS;
    SHEET 1;
    VNAMES 1;
    FIRST 4;
    NROWS 10000.
    XIndplot ‘Vpp’;
    GSAVE “C:\Minitab_Project_Report\vpp.JPG”;
    JPEG.
    XIndplot ‘BW’;
    GSAVE “C:\Minitab_Project_Report\bw.JPG”;
    JPEG.
    XIndplot ‘Fc’;
    GSAVE “C:\Minitab_Project_Report\fc.JPG”;
    JPEG.
    XIndplot ‘PL’;
    GSAVE “C:\Minitab_Project_Report\pl.JPG”;
    JPEG.

    GMANAGER;
    ALL;
    CLOSE;
    NOPROMPT.
    WORKSHEET “Data of the pulse-echo”;
    CLOSE;
    NOPROMPT.
    STOP.

    ENDMACRO

    • Maybe something that I forgot to say is that this kind of graphs you achieve going to Assistant, then to Graphical Analysis, and once there click on Individual Value Plot

    • Another doubt that I have about this kind of graphs is, how can I put into the this graph gridlines and a reference line using the macro? In the other kind of IVP (the simplest) is really easy, I just need to write:

      Indplot ‘BW’;
      Grid 2;
      MGrid 2;
      Reference 2 25;
      Intbar;
      Individual;
      Mean;
      CMean;
      Median;
      CMedian.

      • Kevin,

        You are seeing the difference between the “true” graphs that are under the graph menu from those under the Stat or Assistant menu. The “true” graphs lets you do extensive customization. The Stat/Assistant graphs have very limited capabilities for customization unless you do it interactively which precludes its use in a macro.

        I did get an idea from the Minitab blog http://blog.minitab.com/blog/applying-statistics-in-quality-projects/using-macros-to-publish-statistical-reports that deals with the “only the last of the three graphs” aspect of the problem. If you use the commands

        gman;
        append.

        you can get the last graph produced however, the catch is I don’t think you can save the ReportPad in a macro!!

        I’d call the Minitab help desk. They have been very helpful to me in the past and even if they confirm what I think – i.e. that you can’t save the XIndPlot as you wish – they may use it as a suggestion for a future release.

        They might also have workarounds.

        One workaround that comes to mind is to generate the statistics with macro code, save them in constants and then use the Inplot and output the constants along with descriptive text as footnotes. If you resize the graph area and put the footnotes to the right of the graph you could get something quite similar to XIndPlot.

        Good Luck.

        • Hi Mark, me again, I am working harder on this, and I get a code that works so good when I place it direct to the command line, but when I use my GMACRO, it shows me an error that say “Unknown Minitab command: OFFSET 1,02 0,8;.”. I did it with a lot of footnotes and work very well, but I don’t understand where is the problem. Below I show you a little bit of my code:

          LET K1 = c5[1]
          LET K2 = c6[1]
          LET K3 = c7[1]
          LET K4 = c8[1]
          LET K5 = c9[1]
          LET K6 = c10[1]
          LET K7 = c11[1]
          LET K8 = c12[1]
          LET K9 = c13[1]
          LET K10 = c14[1]
          LET K11 = c15[1]

          Indplot ‘Vpp’;
          Scale 2;
          HDisplay 1 1 0 0;
          Grid 2;
          MGrid 2;
          Reference 2 400 900;
          Footnote “Descriptive Statistics”;
          OFFSET 1,1 0,84;
          Footnote “Mean: ”
          OFFSET 1,02 0,8;
          Footnote K1;
          OFFSET 1,3 0,8;
          Footnote “StDev: ”
          OFFSET 1,02 0,76;
          Footnote K2;
          OFFSET 1,3 0,76;
          Footnote “Variance: ”
          OFFSET 1,02 0,72;
          Footnote K3;
          OFFSET 1,3 0,72;
          Footnote “1st Qt: ”
          OFFSET 1,02 0,68;
          Footnote K4;
          OFFSET 1,3 0,68;
          Footnote “Median: ”
          OFFSET 1,02 0,64;
          Footnote K5;
          OFFSET 1,3 0,64;
          Footnote “3rd Qt: ”
          OFFSET 1,02 0,60;
          Footnote K6;
          OFFSET 1,3 0,60;
          Footnote “IQR: ”
          OFFSET 1,02 0,56;
          Footnote K7;
          OFFSET 1,3 0,56;
          Footnote “Min: ”
          OFFSET 1,02 0,52;
          Footnote K8;
          OFFSET 1,3 0,52;
          Footnote “Max: ”
          OFFSET 1,02 0,48;
          Footnote K9;
          OFFSET 1,3 0,48;
          Footnote “Range: ”
          OFFSET 1,02 0,44;
          Footnote K10;
          OFFSET 1,3 0,44;
          Footnote “N: ”
          OFFSET 1,02 0,40;
          Footnote K11;
          OFFSET 1,3 0,40;
          MeaLabel;
          YValue;
          Intbar;
          Individual;
          Mean;
          CMean;
          Median;
          CMedian;
          DATA 0,1 0,95 0,1 0,85;
          FIGURE 0 0,7 0 1;
          GSAVE “C:\Minitab_Project_Report\capavpp.JPG”;
          JPEG.

          • Problem solved Mark, do not take time to answer, is just that in the macro the decimal separator is the dot, and that I do not placed “;” after each footnote like ‘Footnote “Min: ” ‘, thanks a lot for your help, definitively your recommendation was useful.

          • Kevin,

            I’m glad it worked out. I’m guessing you created the graph footnotes starting with the code and that is why you used the European decimal separator?

            Here is the approach I’d take:

            Add the footnotes by right clicking on the graph and selecting

            Add > Footnote

            Do this as many times as needed and use placeholder text – eg. the text only portion of your footnotes.

            Re-position the footnotes as needed & resize and re-position the graph area as needed.

            With the graph still having focus, click

            Editor > Copy Command Language

            Paste that code into your text editor and then modify. e.g.

            Footnote “Mean: “;
            Offset 0.859375 0.546719868466524;
            Left;

            might become:

            Let k1 = concatenate(“Mean: “,c5[1])

            ….

            Footnote k1;
            Offset 0.859375 0.546719868466524;
            Left;

            Just my two cents worth…

            Mark

  21. I need to write a macro in Minitab that will take the data I insert and graph/set my limits. The data will contain a date column, grade column, and a few other data variables. The number of data variables will vary between 1 and 12. First I want to split by grade. For each grade I need to make an I-chart for each variable. I need to retain the limits. For each variable I-chart, I need to make a normal capability analysis graph. The lower spec will be the LCL from the I-chart, and the upper spec will be the UCL from the I-chart. I need to retain the mean and standard deviation overall from that graph. Next I need to multiply the stand deviation by 3 and add it to the mean and subtract it from the mean to get my new limits. The new limits will be added to the I-chart as reference lines. I would also like to display the new limits in a window or sheet if possible. If you can help at all I would appreciate it. I’m new to Minitab macros and am unsure of how to proceed.

    • Sorry for the delay in replying. Being retired, I took the summer off!

      Most, if not all, of what you want to do sounds possible. I’d check out the Session Command help and on this website I’d look at the code for the examples in the “How To” tab. I’ve worked several complex examples that do things similar to what you are looking to do…

      Cheers – Mark

  22. Hi.

    Do you know of a way of setting a set of variables, and running a loop through them?

    For example, below I have a script that will plot a single chart for a specific K3 (SOURCE) and K4 (PROPERTY). I’d like to have a list of sources and properties (as well as different reference line values, K7 and K8), that minitab can loop through and create all my charts.

    I imagine a list of the following:

    Sources: (source1, Source 1, Source2, Source3, etc.)
    Properties: (property2, property3, property1, property6, etc.)
    Referencemin (5,7,0,6, etc)
    Referencemax(9,11,32,12, etc.)

    Are you able to suggest anything? Thanks

    Stat ‘Result’;
    By C3 C5;
    GValues C101 C102;
    N C103.
    #C101 and C102 contain all the unique combinations for the values in C3 and C5
    #C103 contains the counts for each combination.
    #If the count is 0 or 1, then skip that combination

    Let K1 = Count(C103)
    DO K2 = 1:K1

    #The commands below ensures that there are at least 2 consecutive data pts.
    if C103[K2] > 1 #and K6 > 0
    PRINT K2
    Let K3 = C101[K2] # SAMPLE SOURCE
    Let K4 = C102[K2] # PROPERTY
    Let K5 = concatenate(k3,” “,k4)

    IF K3 = “SOURCE1” AND K4 = “PROPERTY1” # SOURCE and PROPERTY
    Let K6 = “” # UNITS
    Let K7 = 5 # Min Spec (use 0 if no spec limit)
    Let K8 = 0 # Max Spec (use 0 if no spec limit)
    Let K9 = concatenate(K5,K6) # Plot Title
    Let K10 = concatenate(“\\filelocation\test\”,K5)

    if K7 = 0 AND K8 = 0
    Layout;
    gsave K10;
    emf;
    replace.

    IChart ‘Result’;
    Title K9;
    Stamp C100;
    Include;
    Where “C3=K3 AND C5=K4”;
    figure 0 1 0 1.
    endlayout
    elseif K7 = 0
    Layout;
    gsave K10;
    emf;
    replace.

    IChart ‘Result’;
    Title K9;
    Stamp C100;
    Reference 2 K8 ;
    Placement -1 1;
    Include;
    Where “C3=K3 AND C5=K4”;
    figure 0 1 0 1.
    endlayout
    elseif K8 = 0
    Layout;
    gsave K10;
    emf;
    replace.

    IChart ‘Result’;
    Title K9;
    Stamp C100;
    Reference 2 K7 ;
    Placement -1 1;
    Include;
    Where “C3=K3 AND C5=K4”;
    figure 0 1 0 1.
    endlayout
    else
    Layout;
    gsave K10;
    emf;
    replace.

    IChart ‘Result’;
    Title K9;
    Stamp C100;
    Reference 2 K7 K8;
    Placement -1 1;
    Include;
    Where “C3=K3 AND C5=K4”;
    figure 0 1 0 1.
    endlayout
    endif

    Else
    #Do Nothing
    ENDIF

  23. Hi Mark

    When saving graphs I usually use the following command example:
    gsave “C:\Graphs\5.0 IJ1100\5-9-6.jpg”;
    replace;
    jpeg.

    This works fine for most graph types but not for the follow example:
    MCapa ‘Amount of electrolyte’;
    Size 1;
    By ‘Line No’ ‘Chamber’ ‘Dispenser’;
    LSpec 149.7;
    USpec 154.1;
    Pooled;
    AMR;
    UnBiased;
    OBiased;
    Target 151.9;
    GHistogram;
    DScaling;
    Tolerance 6;
    Overall;
    CStat.

    How do I save this type of graph in a macro or exe file?

    Cheers Keith

    • You are asking Minitab to save multiple graphs to a single file name which doesn’t work. If you look on this website at How To > Weibull for Yield Control Chart you will see an approach that builds a stats table and then marches through it in a Do loop to subset the data for one combination (in your case ‘Line No’ ‘Chamber’ ‘Dispenser’). From that subset you can then generate the specific graph. You would need to use Capa instead of MCapa.

      Here is code for another example that does the subsetting within the graphing command itself using an Include / Where statement. Look at the sub-macro GraphsByStn. Unfortunately the indenting usually gets lost when I paste the code so it becomes harder to read.

      Good Luck – Mark

      # Wind_Power.mac – Macro to manipulate IESO wind power data and generate graphs
      #
      # M.A. Sibley Consulting, Kingston, Ontario. Copyright 2011
      #
      # 2010-10-12 MAS – New Macro
      # 2011-10-18 – Add CSV File Saves
      # 2011-11-14 – Change ODBC code due to office upgrade???
      # 2012-11-25 MAS – Change ODBC code after PC Rebuild
      # 2016-02-19 MAS – Move to OneDrive

      gmacro
      Wind_Power

      Call GetData
      Call ManipulateData
      Call MakeGraphs
      Call GraphsByStn
      Call SaveWorksheets

      endmacro

      ################################################################################
      # GetData
      ################################################################################

      gmacro
      GetData

      # Name blank worksheet

      worksheet;
      rename “WindTotals”.

      # Use ODBC to read selected columns from Excel workbook

      ODBC;
      Connect “DSN=Excel Files;” &
      “DBQ=C:\Users\marka\OneDrive\Documents\MTB\Data\Wind\IESO Wind Data.xls;” &
      “DefaultDir=C:\Users\marka\OneDrive\Documents\MTB\Data\Wind;” &
      “DriverId=1046;MaxBufferSize=2048;PageTimeout=5;”;
      SQLString &
      “SELECT ” &
      “`DateTime`, ” &
      “`Generator`,” &
      “`Capability`,” &
      “`Output` ” &
      “FROM ” &
      “`WindSummary$` ” &
      “where ” &
      “`Generator`=’WIND Total'”.

      # Name blank worksheet

      new
      worksheet;
      rename “WindByStation”.

      # Use ODBC to read selected columns from Excel workbook

      ODBC;
      Connect “DSN=Excel Files;” &
      “DBQ=C:\Users\marka\OneDrive\Documents\MTB\Data\Wind\IESO Wind Data.xls;” &
      “DefaultDir=C:\Users\marka\OneDrive\Documents\MTB\Data\Wind;” &
      “DriverId=1046;MaxBufferSize=2048;PageTimeout=5;”;
      SQLString &
      “SELECT ” &
      “`DateTime`, ” &
      “`Generator`,” &
      “`Capability` ,” &
      “`Output` ” &
      “FROM ” &
      “`WindSummary$` ” &
      “where ” &
      “`Generator`<>‘WIND Total'”.

      endmacro

      ################################################################################
      # ManipulateData
      ################################################################################

      gmacro
      ManipulateData

      # Create column for average Capability and output during period

      Name c8 “MnCapability” c9 “MnOutput”
      Statistics ‘Capability’ ‘Output’;
      By ‘Generator’;
      Expand;
      NoEmpty;
      Mean ‘MnCapability’-‘MnOutput’.
      Name c10 “MaxCapability”
      Statistics ‘Capability’;
      By ‘Generator’;
      Expand;
      NoEmpty;
      Maximum ‘MaxCapability’.

      # Define output as % of Capability to nearest 10%

      Name C11 ‘% of Capability’
      Let ‘% of Capability’ = if(‘MnOutput’< 'MnCapability'*0.9,round('Output'*10/'Capability')*10,'*') Name C12 'PerCent of Max Capability' Let 'PerCent of Max Capability' = 'Output'*100/'MaxCapability' # Do Time of Day statistics Name C14 'TimeOfDay' Let 'TimeOfDay' = when('DateTime' - Floor('DateTime')) Date TimeOfDay TimeOfDay; Format (DT hh:mm). # Do Time of Day statistics Name C15 'Day' Let 'Day' = when(Floor('DateTime')) Date Day Day; Format (DT YYYY-MM-DD). # Create table listing all stations Name c28 "Stn" c29 "Cap (MW)" c30 "Out (MW)" Statistics 'Capability' 'Output'; By 'Generator'; Missings; GValues 'Stn'; Mean 'Cap (MW)' 'Out (MW)'. # Create table of Station Numbers and use to add station number to table of stats Name C31 'StnNo' Let 'StnNo' = pars('Stn'<>“Not Found”)

      # Define max station number

      Name k10 “kMaxStnNo”
      Let ‘kMaxStnNo’ = max(StnNo)

      Name c13 “StationNo”
      Convert ‘Stn’ ‘StnNo’ ‘Generator’ ‘StationNo’.

      # Generate Stats by Time of Day

      Name c37 “Location” c38 “HourStarting” c39 “AvgOutput (MW)”
      Statistics ‘Output’;
      By ‘Generator’ ‘TimeOfDay’;
      GValues ‘Location’-‘HourStarting’;
      Mean ‘AvgOutput (MW)’.

      endmacro

      ################################################################################
      # MakeGraphs
      ################################################################################

      gmacro
      MakeGraphs

      # Switch to original worksheet

      Worksheet “WindTotals”

      # Create the sub-title

      let C199 = now() # C199 is an empty column
      date C199 C199; # The now() function returns time as a number;
      format(dt yyyy-mm-dd hh:mm). # convert to date in international format
      text C199 C199 # Convert the date to a text string
      Let k1 = CONCATENATE(“Last Updated: ” ,C199)
      erase C199 # Erase no longer needed column

      # Define Date Range

      Name k20 “kMinDay”
      Name k21 “kMaxDay”
      Let ‘kMaxDay’ = max(floor(DateTime))+0.5
      Let ‘kMinDay’ = min(floor(DateTime))-0.5

      # Date into International Date Format from an internal date number or another date format

      Date ‘DateTime’ ‘DateTime’;
      Format (DT YYYY-MM-DD).

      # Plot total wind power output vs Capability

      Plot ‘Output’ * DateTime &
      ‘Capability’ * DateTime;
      Scale 1;
      PSize 8;
      Angle 90;
      NMajor 25;
      Min ‘kMinDay’;
      Max ‘kMaxDay’;
      Scale 2;
      Min 0;
      AxLabel 1;
      ADisplay 0;
      AxLabel 2 “MW”;
      ADisplay 1;
      NoLegend;
      Overlay;
      NoJitter;
      Connect;
      Type 1 1 3 4 5;
      Color 1 9 52 4 42 6 84;
      Size 1 3;
      Symbol;
      Type 6 0 16 20 23 26 29 2 3 4;
      Color 2 9;
      Size 0.7 0.7;
      Grid 1;
      Grid 2;
      Title &
      “Wind Power Generated (Red) vs Capability (Green)”;
      SubTitle k1;
      PSize 8;
      TColor 4;
      Center;
      Footnote;
      FPanel;
      NoDTitle;
      gsave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\TotalOutToCap.jpg”;
      replace;
      jpeg.

      # Change Worksheet

      Worksheet “WindByStation”

      # Create the sub-title

      let C199 = now() # C199 is an empty column
      date C199 C199; # The now() function returns time as a number;
      format(dt yyyy-mm-dd hh:mm). # convert to date in international format
      text C199 C199 # Convert the date to a text string
      Let k1 = CONCATENATE(“Last Updated: ” ,C199)
      erase C199 # Erase no longer needed column

      # Date into International Date Format from an internal date number or another date format

      Date ‘DateTime’ ‘DateTime’;
      Format (DT YYYY-MM-DD).

      # Define Date Range

      Name k20 “kMinDay”
      Name k21 “kMaxDay”
      Let ‘kMaxDay’ = max(floor(DateTime))
      Let ‘kMinDay’ = ‘kMaxDay’ – 10

      Plot StationNo * DateTime;
      Scale 1;
      PSize 8;
      Angle 90;
      NMajor 16;
      Min ‘kMinDay’;
      Max ‘kMaxDay’;
      Scale 2;
      MODEL 1;
      Tick 1:kMaxStnNo/1;
      Label c28;
      EndMODEL;
      AxLabel 1;
      ADisplay 0;
      AxLabel 2;
      ADisplay 0;
      NoJitter;
      Legend;
      Section 1;
      Symbol ‘% of Capability’;
      Type 0 12 12 12 12 12 12 12 12 12 12 0;
      Color 0 1 2 3 4 5 6 7 8 9 10 0;
      Size 1 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 1;
      Grid 1;
      Grid 2;
      Type 1;
      Color 78;
      Size 1;
      Footnote;
      FPanel;
      SubTitle k1;
      PSize 8;
      TColor 4;
      Center;
      Title &
      “Output % (for Wind Farms with defined Capacities)”;
      NoDTitle;
      gsave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\StatusView.jpg”;
      replace;
      jpeg.

      Name k3 “kDaysAgo”

      Let ‘kDaysAgo’ = 1 # Yesterday
      Call StatusViewByDay

      Let ‘kDaysAgo’ = 2 # 2 Days ago
      Call StatusViewByDay

      Let ‘kDaysAgo’ = 3 # 3 Days ago
      Call StatusViewByDay

      Let ‘kDaysAgo’ = 4 # 4 Days ago
      Call StatusViewByDay

      Let ‘kDaysAgo’ = 5 # 5 Days ago
      Call StatusViewByDay

      Let ‘kDaysAgo’ = 6 # 6 Days ago
      Call StatusViewByDay

      Let ‘kDaysAgo’ = 7 # 7 Days ago
      Call StatusViewByDay

      # Date into International Date Format from an internal date number or another date format

      Date ‘DateTime’ ‘DateTime’;
      Format (DT YYYY-MM-DD).

      Histogram ‘MnOutput’ ‘Capability’ ‘Output’;
      Scale 1;
      PSize 9;
      Angle 90;
      Min -5;
      Scale 2;
      Max 53;
      AxLabel 1 “MW”;
      ADisplay 1;
      NoLegend;
      NoTable;
      Overlay;
      Panel Generator;
      Margin 0.01;
      NoAlternate;
      Label;
      Bold;
      Midpoint 0:200/5 ;
      Percent;
      Bar;
      Type 1 1 1 ;
      Color 1 2 3 ;
      Grid 1;
      SubTitle;
      StDist;
      SubTitle k1;
      PSize 8;
      TColor 4;
      Center;
      Title “Histograms of Wind Power Output (Avg: Black) vs Capability (Red)”;
      NoDTitle;
      NoDFootnote;
      gsave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\HistByStn.jpg”;
      replace;
      jpeg.

      Plot ‘AvgOutput (MW)’ * HourStarting;
      Scale 1;
      PSize 8;
      Angle 90;
      MODEL 1;
      Min 0;
      Max 0.983;
      EndMODEL;
      NoJitter;
      Legend;
      PSize 6.5;
      Section 1;
      Connect Location;
      Type 1;
      Size 2;
      Symbol Location;
      Size 0.6;
      Grid 1;
      Grid 2;
      Footnote;
      FPanel;
      Title &
      “Hourly Average Output vs Time of Day”;
      SubTitle k1;
      PSize 8;
      TColor 4;
      Center;
      NoDTitle;
      gsave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\OutputByHr.jpg”;
      replace;
      jpeg.

      Plot ‘Capability’ * ‘DateTime’ &
      ‘Output’ * ‘DateTime’;
      Scale 1;
      PSize 8;
      Angle 90;
      NMajor 8;
      Scale 2;
      NMajor 5;
      AxLabel 1;
      ADisplay 0;
      AxLabel 2 “MW”;
      ADisplay 1;
      NoLegend;
      Overlay;
      Panel Generator;
      Margin 0.006;
      NoAlternate;
      NoJitter;
      Data 0.0929 0.9753 0.1412 0.9076;
      Connect;
      Type 1 1 3 4 5;
      Color 57 2 52 4 42 6 84;
      Size 2 1;
      Symbol;
      Type 0;
      Color 1 2 52 4 42 6 84;
      Size 0.5;
      Grid 1;
      Grid 2;
      SubTitle k1;
      PSize 8;
      TColor 4;
      Offset 0.002352 -0.051;
      Center;
      Title “Power Output vs Capability for Ontario Wind Power WindSites”;
      PSize 10;
      Offset 0.00235 -0.011510;
      NoDTitle;
      NoDFootnote;
      gsave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\OutputBySite.jpg”;
      replace;
      jpeg.

      # Define Date Range

      Name k20 “kMinDay”
      Name k21 “kMaxDay”
      Let ‘kMaxDay’ = max(floor(DateTime))
      Let ‘kMinDay’ = ‘kMaxDay’ – 10

      Plot ‘Output’ * DateTime;
      INCLUDE;
      WHERE “‘MnCapability’>100”;
      Scale 1;
      PSize 8;
      Angle 90;
      NMajor 11;
      Min ‘kMinDay’;
      Max ‘kMaxDay’;
      AxLabel 1;
      ADisplay 0;
      NoJitter;
      Data 0.1259 0.8024 0.1983 0.8941;
      Legend 0.8153 0.9871 0.66 0.8941;
      PSize 6;
      Section 1;
      Connect Generator;
      Type 1;
      Grid 1;
      Grid 2;
      SubTitle k1;
      PSize 8;
      TColor 4;
      Offset 0.002352 -0.0644;
      Center;
      Title &
      “Ontario Wind Farms – Major Stations (Cap > 100 MW)”;
      PSize 11;
      Offset 0.001176 -0.0206143;
      Footnote;
      FPanel;
      NoDTitle;
      gsave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\OutputSiteOverlay.jpg”;
      replace;
      jpeg.

      Chart MEAN(‘Output’) * Day;

      # Use where clause to limit time span of graph and skip plotting last day with only 1 hour available

      Include;
      Where “(Day>max(Day)-42)and(DateTime<>max(DateTime)and(TimeOfDay=0))”;

      Scale 1;
      PSize 8.5;
      Angle 90;
      TIncrement 2;
      AxLabel 1;
      LShow 1 2;
      AxLabel 2 ” MW”;
      ADisplay 1;
      TShow 1 2;
      GapWidth 0.5;
      Group Generator;
      Stack 1;
      Data 0.1212 0.7976 0.2084 0.8874;
      Legend 0.8153 0.9882 0.316 0.8874;
      PSize 7;
      Section 1;
      Bar;
      Type 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 2 &
      2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 ;
      Color 26 3 126 36 11 77 37 57 70 68 38 &
      82 67 46 63 2 3 126 36 11 77 37 57 85 68;
      EType 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
      EColor 1 1 1 1 1 1 1 1 126 1 1 1 1 1 1 1;
      ESize 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
      SubTitle k1;
      PSize 8;
      TColor 4;
      Offset 0.002352 -0.0711;
      Center;
      Title &
      ” Daily Output (Avg of Hourly Data)”;
      Offset 0.0011764 -0.0206;
      Footnote;
      FPanel;
      NoDTitle;
      gsave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\BarChartByDay.jpg”;
      replace;
      jpeg.

      endmacro
      ################################################################################
      # StatusViewByDay
      ################################################################################

      gmacro
      StatusViewByDay

      # Date into International Date Format from an internal date number or another date format

      Date ‘DateTime’ ‘DateTime’;
      Format (DT YYYY-MM-DD HH:MM).

      # Define Date Range

      Name k20 “kMinDay”
      Name k21 “kMaxDay”
      Let ‘kMaxDay’ = max(floor(DateTime)) – ‘kDaysAgo’ + 1
      Let ‘kMinDay’ = ‘kMaxDay’ – 1

      # Define Day of Week

      let c17 = kMinDay
      date c17 c17
      Text C17 c17;
      Wkday.

      Name k2 “kTitle”
      Let k2 = concatenate(“Output % (for Wind Farms with defined Capacities) – “,c17)

      Name k4 “kFName”
      Let ‘kFName’ = concatenate(“C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\StatusView”,c17,”.jpg”)

      Plot StationNo * DateTime;
      Scale 1;
      PSize 8;
      Angle 90;
      NMajor 13;
      Min ‘kMinDay’;
      Max ‘kMaxDay’;
      Scale 2;
      MODEL 1;
      Tick 1:kMaxStnNo/1;
      Label c28;
      EndMODEL;
      AxLabel 1;
      ADisplay 0;
      AxLabel 2;
      ADisplay 0;
      NoJitter;
      Legend;
      Section 1;
      Symbol ‘% of Capability’;
      Type 0 12 12 12 12 12 12 12 12 12 12 0;
      Color 0 1 2 3 4 5 6 7 8 9 10 0;
      Size 1 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 1;
      Grid 1;
      Grid 2;
      Type 1;
      Color 78;
      Size 1;
      Footnote;
      FPanel;
      SubTitle k1;
      PSize 8;
      TColor 4;
      Center;
      Title kTitle ;
      NoDTitle;
      gsave kFName;
      replace;
      jpeg.

      endmacro
      ################################################################################
      # GraphsByStn
      ################################################################################

      gmacro
      GraphsByStn

      Name k31 “kInd”
      Name k32 “kNStn”
      Let ‘kNStn’ = count(‘Stn’)

      DO ‘kInd’ = 1 : ‘kNStn’

      Name k2 “kTitle”
      Let k2 = concatenate(‘stn'[‘kInd’], “: Output vs Capability”)
      Name k4 “kFName”
      Let ‘kFName’ = concatenate(“C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\StnOutputVsCap_”,’Stn'[‘kInd’],”.jpg”)

      Name k35 “kMaxY1”
      Let ‘kMaxY1′ = max(if(StationNo=k31,MaxCapability,0))*1.05

      # Only generate graph if there is data

      if max(if(StnNo=k31,’Out (MW)’,0))>0

      Plot &
      MnOutput * DateTime &
      ‘PerCent of Max Capability’ * DateTime &
      Output * DateTime &
      Capability * DateTime;
      INCLUDE;
      WHERE “Generator= Stn[‘kInd’]and(DateTime>max(DateTime-62))”;
      Scale 1;
      PSize 8;
      Angle 90;
      NMajor 16;
      Scale 2;
      Type 1;
      Color 2;
      Size 1;
      TColor 2;
      Bold;
      Min 0;
      Max ‘kMaxY1’;
      Scale 2;
      Type 1;
      Color 57;
      Size 1;
      SecScale ‘PerCent of Max Capability’;
      TColor 57;
      Min 0;
      Max 105;
      AxLabel 1;
      ADisplay 0;
      AxLabel 2 “mW”;
      ADisplay 1;
      TColor 2;
      AxLabel 2;
      SecScale;
      TColor 57;
      NoLegend;
      Overlay;
      NoJitter;
      Connect;
      Type 1 1 1 1;
      Color 1 2 2 57;
      Size 2 1 1 2;
      Symbol;
      Type 0 6 6 0 16 20 23 26 29 2 3 4;
      Color 2 2 2 2 52 4 42 6 84;
      Size 0.6;
      Grid 1;
      Grid 2;
      Type 3;
      Color 29;
      Size 1;
      Grid 2;
      Type 4;
      Color 123;
      Size 1;
      SecScale;
      Footnote;
      FPanel;
      Title ‘kTitle’;
      SubTitle k1;
      PSize 8;
      TColor 73;
      Center;
      NoDTitle;
      gsave ‘kFName’;
      replace;
      jpeg.
      EndIf
      ENDDO

      endmacro
      ################################################################################
      # SaveWorksheets
      ################################################################################

      gmacro
      SaveWorksheets

      # Switch to original worksheet

      Worksheet “WindTotals”

      # Date into International Date Format from an internal date number or another date format

      Date ‘DateTime’ ‘DateTime’;
      Format (DT YYYY-MM-DD HH:MM).

      WSave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\Data\WindTotals.CSV”;
      FType;
      CSV;
      Missing;
      Numeric ‘*’ ‘*’;
      Text “” “”;
      DecSep;
      Period;
      Field;
      Comma;
      TDelimiter;
      DoubleQuote;
      Replace.

      # Change Worksheet

      Worksheet “WindByStation”

      # Date into International Date Format from an internal date number or another date format

      Date ‘DateTime’ ‘DateTime’;
      Format (DT YYYY-MM-DD HH:MM).

      WSave “C:\Users\marka\OneDrive\Documents\MTB\Output\Wind\Data\WindByStation.CSV”;
      FType;
      CSV;
      Missing;
      Numeric ‘*’ ‘*’;
      Text “” “”;
      DecSep;
      Period;
      Field;
      Comma;
      TDelimiter;
      DoubleQuote;
      Replace.

      endmacro

Leave a Reply

Your email address will not be published. Required fields are marked *