BookmarkSubscribeRSS Feed
Banu
Obsidian | Level 7
Hello,

I needs to use ODS Tagsets ExcelXP bygroup option in Proc Report. How can I use group option in Proc Report. Please provide me your suggestions.
8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, you have not really told us anything there.  A good question is one that provides test data, in the form of a datastep (or from sashelp tables), and what the output should look like.  Also, any code you have done towards it or logic needed.

From what I can decode from your post you are talking about two different things.  By group processing does the whole procedure for each by group, define/group sums just block out and summarise data within the one procedure.  Now for by group something like:

ods tagsets.excelxp file="s:\temp\rob\test.xml" options(sheet_interval="bygroup");
proc sort data=sashelp.class out=class;
  by sex;
run;
proc report data=class;
  by sex;
  title '#byval1';
run;
ods tagsets.excelxp close;
Cynthia_sas
SAS Super FREQ
Hi:
I believe there have been other forum postings on the use of BYGROUP processing with TAGSETS.EXCELXP -- the proc you use is typically irrelevant. What people usually want is for the #byval to be used for the sheet_name when they have each BY group start on a different sheet and there is a TAGSETS.EXCELXP option for that -- if you put options(doc='Help') in your ODS invocation statement, you'll see the suboption to use. Otherwise, you could search on the forum for previous examples.

cynthia
Banu
Obsidian | Level 7
Thank you so much RW9 and Cynthia.

Below is my scenario.
Source:

EmpName Empno Sal DeptName
100 Santa 1000 Maths
101 Frank. 2000 Maths
102 Easter 3000 Science
103 Quincy. 4000 History
104 Yesk. 5000 Science

Output:

Excel sheet Name: Class Summary.xlsx
1st tab: Maths

EmpName Empno DeptName Sal
100 Santa Maths 1000
101 Frank Maths 2000
-----------
3000

In the same way,Need Excel sheet tabs name should be Department Names. And each tab displays about the each department details.Need all this information in excel sheet.

I got idea on bygroup in ODs tagsets excelxp , and it's easy to use with Proc print. As per my requirement which procedure is suitable to send group information into excel sheet tabs.Thanks for your info.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, the question is not clear.  Proc report is just a more advanced version of proc print.  Wether you use one or the other is up to you.  Me, I use proc report for all output.  By grouping works on both those, and in fact almost all procedures.

Cynthia_sas
SAS Super FREQ

Hi:

  Well, PROC REPORT or PROC PRINT doesn't matter, what matters is the options and suboptions you use. For example, this code works fine for me to name each sheet with the value of the BY group for that sheet.

proc sort data=sashelp.class out=class;
  by age;
  where age in (12, 13, 14);
run;

options nobyline;

ods excel file='c:\temp\bygrp_excel_sheet_title.xlsx' style=htmlblue
    options(sheet_interval='bygroup' sheet_name="Age: #byval1" embedded_titles='yes');
	  
ods tagsets.excelxp file="c:\temp\bygroup_one_sheet_title.xml" style=htmlblue 
    options(sheet_interval='bygroup' sheet_name="Age: #byval1" embedded_titles='yes');
    
    proc report data=class; 
      by age;
	  column name sex age height weight;
	  title 'Report for Age: #byval(age)';
    run;
ods tagsets.excelxp close;
ods excel close;

Since you did not really provide data nor information about the destination you were using, I just used SASHELP.CLASS and ODS EXCEL and ODS TAGSETS.EXCELXP as proof of concept. You will at least need 9.4 of SAS to run the ODS EXCEL example, but the TAGSETS.EXCELXP example should work in 9.3 as well.

 

cynthia

Banu
Obsidian | Level 7
Thank you so much for all your response. I got the info for what I require.
Banu
Obsidian | Level 7
Could you please let me know what is the meaning of
below default column width option in ods tagsets.excelxp*(Would like to know what's the meaning of all these values)

default_column_width='17.14, 21.57, 17.71, 18.29, 17.29, 15.29, 18.02, 15.86, 16.57, 47.57' width_fudge='0.55');
Cynthia_sas
SAS Super FREQ
Hi:
Please add
options(doc='Help' ... other options) to your ODS TAGSETS.EXCELXP and you can read about the default_column_widths suboption.

cynthia

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!

How to Concatenate Values

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.

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
  • 8 replies
  • 1267 views
  • 0 likes
  • 3 in conversation