BookmarkSubscribeRSS Feed
zhangda
Fluorite | Level 6

 

Hello!

 

I am coding to report in excel workbook attachment, which includes two sheet tabs, one is 2015 product, another is 2016 product. For first sheet tab, I have 2015 products, including four product , A, B, C, D, but why the last product D showing in the first part of the second sheet tab, which is supposed to be 2016 product only. Would you please help me out? The code below is incomplete, just an example, because I am thinking there must be an option that could solve the issue,  the attachment is my result. Thanks!

 

ODS LISTING CLOSE;

ODS TAGSETS.EXCELXP file="/opt/sas/sasmain/Project.xls"

 STYLE=minimal options( Autofit_height='yes'

              frozen_rowheaders='yes' sheet_interval='none' embedded_footnotes='yes'

sheet_label = ' '

 embedded_titles = 'yes'

 suppress_bylines = 'yes' sheet_name='2015 Product

/*              autofilter='all' autofilter_table='2'*/

Orientation = 'landscape' width_fudge='0.1'

);

 

 

ods tagsets.ExcelXP options(sheet_interval='none' sheet_name=2015 Product ');

 

 

 

Proc report data=allproduct_dqm contents="   " nowd split='\'

/*style(report)={font_size=14pt cellpadding=4pt cellspacing=1 rules=none frame=void}*/

style(header)={color=white background=cornflowerblue  height=1.3in fontsize=1.5 }

style(column)={just=center background=snow foreground=black cellwidth=1in   foreground=black  fontsize=1.5};

 title1 j=c  color=black HEIGHT=10pt  BOLD "Credit Metrics for All Products";

column _name_   year2016  year2015   Num_of_Variance mature2015  Num_of_Variance2 y2016 y2015 Variance ;

 

define _name_ / "Metrics"   style=[foreground=negfmt.];

define year2016/  "&Apr_Yr."  style=[foreground=negfmt.];

 

compute _name_ ;

     if _name_= 'Avg FICO'  then call define(_row_,'style','style={background=gainsboro}');

 

endcomp;

 

  %macro comp(arg);    

           compute &arg;      

              If _name_='2015 Product'   then call define(_col_,'format','comma20.0');

              If _name_='CreditAR'   then call

          endcomp;

     %mend common_lines;

 

        

 

 

ods tagsets.ExcelXP options(sheet_interval='none' sheet_name='2016 Product');

 

 

 

Proc report data=allproduct_orig   contents="   " nowd split='\'

style(header)={color=white just=center background=lightgrey fontweight=bold }

style(column)={color=white just=center background=lightcyan foreground=black };

 

column _name_   month2016 month2015 Num_of_Variance Perc_of_Variance   year2016 year2015  Perc_of_Variance_y;

title1 j=c  color=black HEIGHT=10pt  BOLD " All Products";

define _name_ / "Originations"   style=[fontstyle=Roman  fontweight=bold width=2in font_size=2.2 cellwidth=2in just=center foreground=negfmt.];

 

6 REPLIES 6
ChrisHemedinger
Community Manager

Others might have input on your format and approach, but my first advice is this.  If you have SAS 9.4m3, use ODS EXCEL instead of ODS TAGSETS.EXCELXP.  The syntax is nearly identical, and you'll get a native xlsx file that's much smaller in size and more acceptable to Microsoft Excel.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, its not going to be possible to work out any issue from that.  The code is mostly missing, and I wouldn't download any Excel files due to security risks.  Post some example test data - just a couple of lines, in a datastep, and the full export code so that we can run it.  If a variable is really appearing on another sheet then I imagine the code - with the macro part - is not resolving correctly - however I can't see your log so can't tell you.  If its just appearing on another page, you have too many variables for one page.

 

One other tip, post code in code window - {i} or the SAS run symbol above the post area.  Remove commented blocks, use consistent indetation and capitilisation to make code as readbel as possible, 

 

Sorry, looking at it further there are nnumerous errors/typos in that code, here I updated a bit for you.  There are no product A B C D variables given anywhere, are these observations if so then that is what is in that dataset:

ods listing close;
ods tagsets.excelxp file="/opt/sas/sasmain/Project.xls"
  style=minimal options( Autofit_height='yes'
        frozen_rowheaders='yes' sheet_interval='none' embedded_footnotes='yes'
        sheet_label = ' '
        embedded_titles = 'yes'
        suppress_bylines = 'yes' sheet_name='2015 Product' Orientation = 'landscape' width_fudge='0.1');
ods tagsets.ExcelXP options(sheet_interval='none' sheet_name='2015 Product ');
 
Proc report data=allproduct_dqm contents="   " nowd split='\'
  style(header)={color=white background=cornflowerblue  height=1.3in fontsize=1.5 }
  style(column)={just=center background=snow foreground=black cellwidth=1in   foreground=black  fontsize=1.5};
  title1 j=c  color=black HEIGHT=10pt  BOLD "Credit Metrics for All Products";
  column _name_   year2016  year2015   Num_of_Variance mature2015  Num_of_Variance2 y2016 y2015 Variance ;  /* <- this shows the columns to output */

Example of typo: ods tagsets.ExcelXP options(sheet_interval='none' sheet_name=2015 Product ');

Missing quote before 2015. 

ballardw
Super User

When you use

(sheet_interval='none'

it means just that, all the data goes to the same sheet until a different interval is specified in an ODS tagsets.excelxp statement.

 

You may want (sheet_interval='proc'

to send all of the output to one sheet from a single Procedure call or if you have a procedure that generates multiple tables then 'table'

 

But since you have columns with names like year2016  year2015   y2016 y2015 in a single proc report definition it appears that you really do not want to separate the years.

 

If you have a variable to split the report on then use the BY statement in the proc and the table option for the sheet_interval. Maybe.

zhangda
Fluorite | Level 6
 
But I have 12 tables generated by proc report procedures. I want to display table 1-6 in the sheettab1, and 7-12 in sheettab2, they are not divided by group, thanks!
ballardw
Super User

Your easiest solution may be to add a variable to group them by and use Sheet_Interval = 'Bygroup'. Which would put the output for separate values of the BY variable on separate sheets.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Its simply a matter of putting your proc reports in the right place:

ods tagsets.excelxp file=... options(sheet_name="First sheet" ...);
proc report data=table1...
proc report data=table2...
...

ods tagsets.excelxp options(sheet_name="Second sheet"...);
proc report data=table7...
...

ods tagsets.excelxp close;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1208 views
  • 0 likes
  • 4 in conversation