At the end of a lengthy collection Macros and Procedures when I end the same with the following code:
PROC TABULATE DATA=RESULTS2 OUT=CHK2;
CLASS PRODUCT DPD_BUCKET DATA_MONTH;
VAR TOTAL_OS COUNT_OS;
TABLE PRODUCT, DPD_BUCKET, TOTAL_OS*DATA_MONTH;
RUN;
It presents an excellent Cross Tabulated Pivot Like format in OutPut Window. however, when I select and run only this last piece of code after clearing up the Output Window and Log with F12 the table never appears again:
ods tagsets.excelxp file="ExcelResultsA.xls";
proc PRINT data=RESULTS;
run; quit;
ods _all_ close;
Any particular reason?
Furthermore, how to export such an appearing table in the similar Pivot like manner in Excel via ODS?
Thanx in advance.
Do you want the cross tab appearance, then run proc tabulate.
Proc print as shown is referencing the input to tabulate and print only knows rows, no nesting or crossing. You may have meant to try to print the output data set CHK2 but it would still not be the cross tab output.
you probably want
ods tagsets.excelxp file="ExcelResultsA.xls";
PROC TABULATE DATA=RESULTS2 OUT=CHK2;
CLASS PRODUCT DPD_BUCKET DATA_MONTH;
VAR TOTAL_OS COUNT_OS;
TABLE PRODUCT, DPD_BUCKET, TOTAL_OS*DATA_MONTH;
RUN;
ods tagsets.excelxp close; /* the _all_ close sometimes causes problems as no output destinations are open after runing the first time*/
Do you want the cross tab appearance, then run proc tabulate.
Proc print as shown is referencing the input to tabulate and print only knows rows, no nesting or crossing. You may have meant to try to print the output data set CHK2 but it would still not be the cross tab output.
you probably want
ods tagsets.excelxp file="ExcelResultsA.xls";
PROC TABULATE DATA=RESULTS2 OUT=CHK2;
CLASS PRODUCT DPD_BUCKET DATA_MONTH;
VAR TOTAL_OS COUNT_OS;
TABLE PRODUCT, DPD_BUCKET, TOTAL_OS*DATA_MONTH;
RUN;
ods tagsets.excelxp close; /* the _all_ close sometimes causes problems as no output destinations are open after runing the first time*/
Thanx Ballard!
Sure do appreciate your explanation!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.