BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
XiaoGuaiShou
Obsidian | Level 7

Hello SAS people,

 

I made a table with proc tabulate in ods html, it works well in sas base, but the title is wrapping together in ods html(I use excel to do an example to show my problem in orange circle). I am not sure if anyone have some idea to solve this problem. 

Any help would be greatly appreciated.

 

Thanks,

 

Smiley Very HappyThe table I want( title spreading out):

Capture.PNG

 

Smiley IndifferentThe table I have(title wrapping):

Capture.PNG

 

Smiley Wink Code I use:

 

data have;
   infile datalines dlm=',';
   informat cat finished 8.  Question $20. ;
   input cat finished Question ;
datalines;
1 ,1,Very often
1 ,1,Never
2 ,1,often
3 ,1,Sometimes
3 ,1,Very often
3 ,1,often 
4 ,1,Never 
5 ,1,Sometimes

;
run; 
data have;
  set have;
  label question	='bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla';
run;

/*ODS HTML3 body=_webout  (no_top_matter no_bottom_matter)  path=&_tmpcat (url=&_replay) rs=none stylesheet=(URL="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css");
*/
	proc tabulate data =have style = [just=c vjust=m ];
		    class Question/  order=internal  &ascending preloadfmt;
			var finished;
			class cat/ order=formatted preloadfmt;
			classlev cat / style = [cellwidth=135];
			keylabel all='Total';
			
		table cat='' all={S = {background = #E7E6D5}}*{S = {background = #E7E6D5 /*cellwidth=70*/}}
		,finished='Respondents'*n=''*f=comma10.  question*(rowpctn=''*f=pct. )/ box={label="Group" s=[just=L ]} ;
	run;
/*ods html3 close;
	ods listing;*/

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  I'm curious why you're using HTML3, however, your code looks like something that used to be submitted to the Application Dispatcher in SAS/IntrNet days. When I change your code to use ODS HTML instead of ODS HTML3, I see only 2 lines for the label.

 

  I am not sure why you have this in the code:

table cat='' all={S = {background = #E7E6D5}}*{S = {background = #E7E6D5 /*cellwidth=70*/}}

That is not how to apply a style to the summary ALL line.

 

 

  When you have this:

proc tabulate data =have style = [just=c vjust=m ];

you are only "touching" the data cells in the table -- the data cells are the cells underneath the column header and to the right of the row header area. So the vjust=m that you have here will NOT have any impact on your header values for Cat, Respondents or Questions -- so if you want vjust=m for the header cells you need to do it in the VAR, CLASS and/or CLASSLEV statements.

 

 

  The table you show as what you currently get, looks like it is restricting the label for QUESTION header cell to the 2 header cells in the middle of your 4 levels. That seems odd to me and worth opening a track with Tech Support about. I'd suggest trying other ODS destinations, like ODS HTML4, ODS MSOFFICE2K and/or ODS HTML5. Since ODS HTML3 was basically the first ODS written for version 7/8, it seems likely to me that later versions of HTML destinations might treat the header cell differently.

 

cynthia

View solution in original post

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  I'm curious why you're using HTML3, however, your code looks like something that used to be submitted to the Application Dispatcher in SAS/IntrNet days. When I change your code to use ODS HTML instead of ODS HTML3, I see only 2 lines for the label.

 

  I am not sure why you have this in the code:

table cat='' all={S = {background = #E7E6D5}}*{S = {background = #E7E6D5 /*cellwidth=70*/}}

That is not how to apply a style to the summary ALL line.

 

 

  When you have this:

proc tabulate data =have style = [just=c vjust=m ];

you are only "touching" the data cells in the table -- the data cells are the cells underneath the column header and to the right of the row header area. So the vjust=m that you have here will NOT have any impact on your header values for Cat, Respondents or Questions -- so if you want vjust=m for the header cells you need to do it in the VAR, CLASS and/or CLASSLEV statements.

 

 

  The table you show as what you currently get, looks like it is restricting the label for QUESTION header cell to the 2 header cells in the middle of your 4 levels. That seems odd to me and worth opening a track with Tech Support about. I'd suggest trying other ODS destinations, like ODS HTML4, ODS MSOFFICE2K and/or ODS HTML5. Since ODS HTML3 was basically the first ODS written for version 7/8, it seems likely to me that later versions of HTML destinations might treat the header cell differently.

 

cynthia

XiaoGuaiShou
Obsidian | Level 7
I really appreciate your help.
Yes, I am using SAS/IntrNet. Thanks for remaindering different ods html style, I choose ODS MSOFFICE2K at end. It works good.
I also check background html code for ODS HTML3, I find SAS makes ODS HTML3 default to leave first and last column blank in the header cell. I only have four columns(very often, often,sometime, never) here, so the title only occupy the middle two columns(often and sometime). if i change it to six columns(eg: always,very often, often, sometime, occasionally,never), so the title can spread to four middle columns(very often, often, sometime, occasionally), it still leaves first and last column blank(always, never),but it won’t looks so strange wrapping.
Summary all line is used to add color to the bottom line.
Thanks.
ballardw
Super User

Value of the macro variable &ascending?

 

The formats involved that you are using Preloadfmt with.

Since they aren't referenced in the proc tabulate code we have to assume that you have them assigned to the variables permanently.

 

Also your Preloadfmt won't work as

PreloadFmt will have no effect on the output without one of the following options:

"printmiss", "order=data", or the class statement option "exclusive".

 

And you show a mean column not referenced in the code.

 

I do know that running your data set without any specific ods options in SAS 9.4 I do not get the heading as you display but in the desired order.

There could also be something in that style sheet.

 

BTW:

data have;
  set have;
  label question	='bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla';
run;

Isn't the best approach. Add the label statement in the code that reads the data or use Proc Data sets. Using a data step to add labels or formats can add significant CPU usage when used with large data sets. Better:

 

data have;
   infile datalines dlm=',';
   informat cat finished 8.  Question $20. ;
   input cat finished Question ;
   label question	='bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla';

datalines;
1 ,1,Very often
1 ,1,Never
2 ,1,often
3 ,1,Sometimes
3 ,1,Very often
3 ,1,often 
4 ,1,Never 
5 ,1,Sometimes

;
run; 

 

 

XiaoGuaiShou
Obsidian | Level 7
Thanks the suggestion about using a data step to add labels or formats. It do can add significant CPU usage when used with large data sets and save a lot of running time. Thanks.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 2015 views
  • 1 like
  • 3 in conversation