Announcement

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

  • Stata .do file saving images in incorrect folders

    I am using Stata/IC 14.2 for Windows (64-bit x86-64).

    I have a long Stata .do file that processes and produces images into particular folders. This code has been working for well over 10-15 years without issue. This past week, the code is sending the images into folders that are different from what the code specifies.

    As an example, the code specifies that the bar chart images be sent to a folder within the "Blinded\New Fields" folder, but actually sent it to a different folder: "Unblinded\New Fields".

    Any help would be appreciated.

    Code:
    graph bar (median) antegrade_target antegrade_actual if (CircArrestCerebDirection==1 | CircArrestCerebDirection==3) &  n_circ~="HFD (37)" & n_circ~="HFM (8)" & n_circ~="LLD (13)" & n_circ~="MUS (3)" & n_circ!="OS14 (15)" & n_circ~="OS19 (23)" & n_circ!="OS21 (100)" & n_circ!="OS5 (170)" & n_circ!="OS6 (20)" & n_circ!="SPT (100)" & n_circ!="UMI (157)",  ylabel(, angle(0)) over(n_circ_blind, label(angle(rvertical) labsize(small)) sort(antegrade_target)) ytitle(Antegrade Cerebral Flows in mL/min) legend(rows(1) label(1 "Target") label(2 "Actual") size(*.5)) title ("Median Antegrade Cerebral Flows (mL/min)" "By Hospital") note("Circulatory Arrest" "Conditional on antegrade cereral flow" "Restricted to Versions 5 and 6" "Only Includes Cases Matched to Surgical Records" "Centers not contributing data on 80% of their cases for this field are excluded", size(*.5))
    graph export "Blinded\New Fields\NEW-antegrade_flowrate.png", width(5178) height(3750) replace
    graph export "Blinded\New Fields\NEW-antegrade_flowrate_optimized.png", width(5178) height(3750) replace

  • #2
    i also have symptoms where i run my code without issues, but not all of the figures are saved to the folders that are specified. my PC is Windows 11 Enterprise, with an Intel (R) Core (TM) i5-14500 2.60 GHz, 64-bit OS processor.

    Comment


    • #3
      There is almost no way that the code you provided could conceivably export the graphs to "Unblinded\New Fields" instead of "Blinded\New Fields". You might want to check the rest of the code to see if some files are being moved (possibly using commands like copy or shell) to see what might be misbehaving.

      Comment


      • #4
        Thank you Hemanshu. I think i have fixed that issue now by using the full length of the pathname in the "graph export" command. Now, it seems that the code runs, but does not export all of the graphs. Some graphs export when i manually run small bits of the code rather than running the entire .do file. Other graph commands do not export the intended graph at all.

        Comment


        • #5
          Manifestly I can't rule out a bizarre but logical explanation of remaining problems, but despite helpful intent on all sides such difficulties are very hard to resolve here. You msy need to contact StataCorp technical support, realising in turn that they may bombard you with all sorts of questions about your code.

          Comment


          • #6
            Thank you Nick.

            Comment


            • #7
              I will hazard a guess here: the code possibly has local macros defined for various export folders. When you run the code piece-wise, locals are not retained in memory, and Stata does not throw errors when it encounters undefined macros, it simply substitutes them with an empty string. This can mean the graphs are exported into an unexpected directory, such as the current working directory at the time that piece of code is executed.

              If you want to retain locals in memory while running code piece-wise, use the "Execute (include)" option. This is in a dropdown on the top-right corner of the do-file editor, with an icon of a page with a blue play button on it, and "Do" written underneath. Don't click the icon, click the down arrow next to it to bring up the menu and select Execute (include) from it.

              Comment

              Working...
              X