Refresh All (graphs and power query) using SAS Code

18 Views Asked by At

Is it possible to update all graphs and data model in an excel template, using SAS Code? I don't have access to use DDE and wanted to avoid using VBA.

For more detail, I have excel(xlsx) files that I update with new SAS data on a recurring basis and I do not want to go into each file in order to refresh. I tried clicking "Refresh upon opening" for connections and pivots and it still doesn't work.

Currently, I use libname to update my tables, and then copy the template over to a new location, but when I open the final file, graphs are not updated.

libname out xlsx "&RPTPATH./Template/&TMPLT.";
data out.TBL_DTS;
    set Dates;
run;
data out.TBL_POPULATION;
    set TBL_POPULATION;
run;
data out.TBL_QUESTIONS;
    set TBL_QUESTIONS;
run;
data out.TBL_QUESTION_RESULTS;
    set TBL_QUESTION_RESULTS;
run;

libname out clear;

* create copy of template file;
filename in "&RPTPATH./Template/&TMPLT."; 
filename out "&RPTPATH./&MH_FLDR./&RPTNM.";
/* copy the file byte-for-byte  */
data _null_;
  length filein 8 fileid 8;
  filein = fopen('in','I',1,'B');
  fileid = fopen('out','O',1,'B');
  rec = '20'x;
  do while(fread(filein)=0);
     rc = fget(filein,rec,1);
     rc = fput(fileid, rec);
     rc =fwrite(fileid);
  end;
  rc = fclose(filein);
  rc = fclose(fileid);
run;

filename in clear;
filename out clear;

I tried using the "Refresh upon opening" selection in connections and in pivot chart options, and copying the file over first before updating tables.

0

There are 0 best solutions below