@nid197
I suggest to you an alternative approach that is less programming, where macros and macro variables are not needed to get months across the top of your output table. Use long data sets, use PROC REPORT. Do not try to create you own wide data set with months across the top, that is time consuming and requires macros and macro variables. This is consistent with Maxim 19, use long data sets, not wide data sets.
I would provide an example of code that does this with your data, if only you would provide data in a usable form, which is not screen captures, but working SAS data step code, like I requested twice already.
So I provide an example of doing this on a different (long) data set:
proc report data=sashelp.prdsal3(where=(state="California"));
columns product month,(actual predict);
define product/group;
define month/across format=monyy7. order=internal;
define actual/sum;
define predict/sum;
run;
See, no macro variables needed to get months across the top of the table. Much less programming required on your part. Easier to maintain and update. Runs faster. No transposing needed because the data is already in the long form that works best for producing this type of output.
I have chopped off months on the right, but they are in the output. Now, what's that, you also want this report by quarters? Piece of cake! Minor change needed. (With macros and macro variables, major changes needed!)
proc report data=sashelp.prdsal3(where=(state="California"));
columns product month,(actual predict);
define product/group;
define month/across format=yyq. order=internal;
define actual/sum;
define predict/sum;
run;
I also suggest to you that from now on you describe the final goal, which is an output table with months across the top of the table. Do not simply describe the coding problem where you get stuck. Not describing the final goal and just describing the part of the code where you get stuck is the XY Problem, and it is an inefficient way for you to get the assistance you need. Had we known at the beginning of this thread that you wanted an output table with months across the top, we could get you there a lot faster than what has actually happened in this thread.
... View more