I am creating a table using particular style according to my requirement. I am having trouble how I can achieve the header that's highlighted in yellow. I have the sample code with out the header highlighted in yellow. Any suggestions? Thanks.
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase nofmterr nobyline;
data class;
set sashelp.class;
col1= name;
col2= sex;
col3= age;
col4= height;
col5= weight;
run;
ods escapechar = '^';
ods noresults;
ods listing close;
ods rtf file = "C:\Users\xx\Desktop\Newfolder\class.rtf" style = table_rtf;
proc report data =class ls = 145 ps = 55 missing nowindows split='|'
headskip headline
style(report)=[bordertopcolor=black bordertopwidth=2] style(header)=[asis=on just=c vjust=t fontweight=bold
font_face= "Times New Roman" background=white borderbottomcolor=black fontsize=9pt];
** titles **;
title1 j = l "class." j = r 'Page ^{thispage} of ^{lastpage}';;
title2 j = l "sas";
title3 j = l "created:&sysdate9 &systime";
title4 j = c "Table ";
title5 j = c "SaS class";
title6 j = c "Practice";
** report **;
column (("First Name ^R/RTF'\brdrb\brdrs\li100\ri100' " col1 col2)("Statistics ^R/RTF'\brdrb\brdrs\li100\ri100' " col3-col5));
define col1 /group order = internal style(header) = [just=l] style(column) = [just=l vjust=b cellwidth=10% asis=on]"Name" ;
define col2 /group order = internal style(header) = [just=l] style(column) = [just=l vjust=b cellwidth=10% asis=on]"Sex";
define col3 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Age" ;
define col4 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Height" ;
define col5 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Weight ";
run;
ods rtf close;
ods listing close;
Opps.
Forget to update the code .
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase nofmterr nobyline; data class; set sashelp.class; col1= name; col2= sex; col3= age; col4= height; col5= weight; run; ods escapechar = '^'; ods noresults; ods listing close; ods rtf file = "c:\temp\class.rtf" style = journal ; proc report data =class ls = 145 ps = 55 missing nowindows split='|' headskip headline style(report)=[bordertopcolor=black bordertopwidth=2] style(header)=[asis=on just=c vjust=t fontweight=bold font_face= "Times New Roman" background=white borderbottomcolor=black fontsize=9pt]; ** titles **; title1 j = l "class." j = r 'Page ^{thispage} of ^{lastpage}';; title2 j = l "sas"; title3 j = l "created:&sysdate9 &systime"; title4 j = c "Table "; title5 j = c "SaS class"; title6 j = c "Practice"; ** report **; column (("First Name ^R/RTF'\brdrb\brdrs\li100\ri100' " col1 col2)("Statistics ^R/RTF'\brdrb\brdrs\li100\ri100' " col3-col5)); define col1 /group order = internal style(header) = [just=l] style(column) = [just=l vjust=b cellwidth=10% asis=on]"Name" ; define col2 /group order = internal style(header) = [just=l] style(column) = [just=l vjust=b cellwidth=10% asis=on]"Sex"; define col3 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Age" ; define col4 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Height" ; define col5 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Weight "; compute before/style(lines)={asis=on just=l borderbottomcolor=black borderbottomwidth=2px font_weight=bold}; line ' Personal Information Age VS BMS'; endcomp; run; ods rtf close; ods listing close;
Hi SASuserlot,
I find your table to be confusing (not well designed). I suggest placing Personal Information instead of First Name, and placing Age vs. BMS instead of Statistics. Then you can get rid of that highlighted line altogether. You may replace Name with First Name if needed.
Hope this helps.
Thanks for your suggestion and sorry if it caused any confusion . However I am not focused on the design, I am more focused on "how I can get a line and the highlighted headers" below the "name and sex header, age vs BMS header below the age. height, weight headers . I given the names Personal information or Age Vs BMS just for sample, it can be any thing for that matter. Is it possible at all!
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase nofmterr nobyline; data class; set sashelp.class; col1= name; col2= sex; col3= age; col4= height; col5= weight; run; ods escapechar = '^'; ods noresults; ods listing close; ods rtf file = "c:\temp\class.rtf" style = table_rtf; proc report data =class ls = 145 ps = 55 missing nowindows split='|' headskip headline style(report)=[bordertopcolor=black bordertopwidth=2] style(header)=[asis=on just=c vjust=t fontweight=bold font_face= "Times New Roman" background=white borderbottomcolor=black fontsize=9pt]; ** titles **; title1 j = l "class." j = r 'Page ^{thispage} of ^{lastpage}';; title2 j = l "sas"; title3 j = l "created:&sysdate9 &systime"; title4 j = c "Table "; title5 j = c "SaS class"; title6 j = c "Practice"; ** report **; column (("First Name ^R/RTF'\brdrb\brdrs\li100\ri100' " col1 col2)("Statistics ^R/RTF'\brdrb\brdrs\li100\ri100' " col3-col5)); define col1 /group order = internal style(header) = [just=l] style(column) = [just=l vjust=b cellwidth=10% asis=on]"Name" ; define col2 /group order = internal style(header) = [just=l] style(column) = [just=l vjust=b cellwidth=10% asis=on]"Sex"; define col3 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Age" ; define col4 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Height" ; define col5 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Weight "; compute before/style(lines)={asis=on just=l}; line ' xxxxxxxxxxxxx yyyyyyyyyyyyyyyyyy'; endcomp; run; ods rtf close; ods listing close;
You always have to keep in mind that how a RTF file is rendered is highly dependent on the software used to display it. Even different versions of MS Word will make it look differently.
Just to illustrate my previous post:
Running @Ksharp 's recent code, the report looks like this
in MacOS TextEdit:
and so in LibreOffice:
Here is what I got.
Opps.
Forget to update the code .
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase nofmterr nobyline; data class; set sashelp.class; col1= name; col2= sex; col3= age; col4= height; col5= weight; run; ods escapechar = '^'; ods noresults; ods listing close; ods rtf file = "c:\temp\class.rtf" style = journal ; proc report data =class ls = 145 ps = 55 missing nowindows split='|' headskip headline style(report)=[bordertopcolor=black bordertopwidth=2] style(header)=[asis=on just=c vjust=t fontweight=bold font_face= "Times New Roman" background=white borderbottomcolor=black fontsize=9pt]; ** titles **; title1 j = l "class." j = r 'Page ^{thispage} of ^{lastpage}';; title2 j = l "sas"; title3 j = l "created:&sysdate9 &systime"; title4 j = c "Table "; title5 j = c "SaS class"; title6 j = c "Practice"; ** report **; column (("First Name ^R/RTF'\brdrb\brdrs\li100\ri100' " col1 col2)("Statistics ^R/RTF'\brdrb\brdrs\li100\ri100' " col3-col5)); define col1 /group order = internal style(header) = [just=l] style(column) = [just=l vjust=b cellwidth=10% asis=on]"Name" ; define col2 /group order = internal style(header) = [just=l] style(column) = [just=l vjust=b cellwidth=10% asis=on]"Sex"; define col3 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Age" ; define col4 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Height" ; define col5 /group order = internal style(header) = [just=c] style(column) = [just=c vjust=b cellwidth=10% asis=on]"Weight "; compute before/style(lines)={asis=on just=l borderbottomcolor=black borderbottomwidth=2px font_weight=bold}; line ' Personal Information Age VS BMS'; endcomp; run; ods rtf close; ods listing close;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.