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,
The table I want( title spreading out):
The table I have(title wrapping):
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;*/
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
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
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;
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: