Hello folks, I have a large volume of tables to process and basically I have the main body of the code ready, but I don't know how to set up a macro to let the whole part of code run by each center. Below is the beginning of my code:
*Macros;
%LET Regctr = WS;
%LET fy = 2022-2023;
%LET RCFULL = Full name of the center;
*Import excel file for data source;
proc import out=&Regctr. datafile= "&inpath\&Regctr..xlsx"
dbms=xlsx replace;
sheet="_&Regctr";
getnames=yes;
run;
*SEPARATE CONTRACTS;
DATA &Regctr.; SET &Regctr.;
UCI_0=INPUT(UCI,12.);
RUN;
DATA &Regctr.; SET &Regctr.;
WHERE UCI_0 NE . ; RUN;
RUN; Main bulk of the code continue to the very end ... and then at the proc report step below:
*---------------------------------SAS output, complete version, separate by tabs------------------------;
ODS EXCEL FILE='Tables.xlsx'
OPTIONS(SHEET_INTERVAL='none' SHEET_NAME='table1' EMBEDDED_TITLES='yes'
TAB_COLOR='green' START_AT='2,4' FROZENHEADERS='yes');
OPTIONS MISSING='0';
ODS ESCAPECHAR='^';
title1 j=center bold font=calibri "my title";
title2 j=center bold font=calibri "some other title";
title3 j=right italic font=calibri "Fiscal Year &fy";
title4 j=right italic font=calibri "Page 1 of 1";
title5 j=left italic font=calibri "&RCFull";
title6 j=left bold font=calibri "All Ages";
PROC REPORT DATA=tbl1 NOWD HEADSKIP HEADLINE SPACING=1
STYLE(report)={width=100%}
STYLE(column)=[background=white fontstyle=roman fontsize=3 fontweight=medium
fontfamily='calibri']
STYLE(header)=[background=white fontstyle=roman fontsize=3 fontweight=bold
fontfamily='calibri']
STYLE(lines)=[background=white fontstyle=roman fontweight=medium
fontfamily='calibri' color=black]
;
...
As you can see, I have a total of 21 centers that I need to run the same code over again, and below is what i am trying to resolve:
how could I set up the macro so that it grabs the two-letter abbreviations (in the above example, WS needs to be changed to another two letter abbreviation such as AB, CB, EB, etc when WS part has finished running) and then also change the full name accordingly?
by the time the code runs towards the end, i also need the macro to save the tables using the two-letter abbreviation, for example, change the current part
ODS EXCEL FILE='Tables.xlsx'
to something like ODS EXCEL FILE='WS.xlsx' and go on...
I feel this might be something easy to accomplish but i can't figure out a proper way, any ideas? Thank you so much!
... View more