In the following code, the first 4 steps just manipulate the SASHELP.Class dataset to illustrate my question.
Is it possible to remove certain row lines from spanned rows as noted below?
%LET FilePath=C:\Folder1\Folder2;
data ClassTable;
set SASHELP.Class;
Section="A";
run;
data ClassTable1;
set SASHelp.Class;
Section="B";
run;
data ClassTable;
set ClassTable ClassTable1;
run;
proc sql noprint undo_policy=none;
delete from ClassTable
where Name like '%J%' and Section="B";
quit;
ods rtf file="&FilePath.\TestRTF.rtf";
ODS escapechar='^';
options nodate nonumber;
proc report data=ClassTable spanrows split='~'
style(Header)=[just=l background=white]
Style(Report) = [Rules=Rows Frame=below];
Column ('^{Style[FontSize=12pt font_face="Times New Roman"]Table 3.2 This is my Table Title}'(Sex Name Section Age Height Weight));
Define Sex / group
style(column)=[
cellwidth=0.6in
Vjust=C]
style(header)=[
background=greybb
just=c
vjust=c] center;
Define Name / Display 'Student~Name'
order order=internal
style(Column)=[
borderleftwidth=1pt
just=c vjust=c]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=graybb
background=graybb
just=c
vjust=c] CENTER;
Define Section / order order=internal
style(Column)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=black
just=c vjust=c]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=black
background=greybb
just=c
vjust=c];
Define Age /
style=[borderrightwidth=1pt]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=graybb
borderrightwidth=1pt
borderrightcolor=black
background=greybb
just=c
vjust=c]
style(Column)=[
CellWidth=0.70in
borderrightwidth=1pt
borderrightcolor=black] CENTER;
Define Height /
Style(Column)=[CellWidth=0.75in]
style(Header)=[
borderrightcolor=graybb
borderleftcolor=black
background=greybb
just=c
vjust=c] CENTER;
Define Weight / display 'Student~^{style[fontstyle=italic]Weight}^'
Style(Column)=[CellWidth=0.75in]
style(Header)=[
borderleftcolor=graybb
borderrightcolor=black
background=greybb
just=c
vjust=c] CENTER;
run;
ods rtf close;
A portion of the output is here.
Is it possible to remove the messily highlighted row line, and all others similar? (for Barbara, Carol, where the Student has an A and B Section)
Hi @mcook ,
There is no medicine for the cure of this complication. A surgery is needed. I use your program and a different dataset zipcode from SASHELP, and ODS TAGSETS.RTF. See the attached code.
Jianmin Long
data zipcode; set sashelp.zipcode;
keep statename city zip countynm;
proc sort data=zipcode;
by statename countynm city zip;
data zipcode; set zipcode;
by statename countynm city zip;
length zipcode $10;
zipcode=compress(put(zip, 10.0));
if last.city=0 then do; zipcode=compress(put(zip, 10.0))||'**'; end;
run;
ODS TAGSETS.RTF file="~/zipcode.rtf";
ODS escapechar='^';
options nodate nonumber;
proc report data=zipcode spanrows split='~'
style(Header)=[just=l background=white]
Style(Report) = [Rules=Rows Frame=below];
Column ('^{Style[FontSize=12pt font_face="Times New Roman"]Table 3.2 This is my Table Title}'(Statename Countynm City Zipcode));
Define statename / group
style(column)=[
cellwidth=1.6in
Vjust=C]
style(header)=[
background=greybb
just=c
vjust=c] center;
Define countynm / Display 'County Name'
order order=internal
style(Column)=[
borderleftwidth=1pt
just=c vjust=c]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=graybb
background=graybb
just=c
vjust=c] CENTER;
Define City / order order=internal
style(Column)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=black
just=c vjust=c]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=black
background=greybb
just=c
vjust=c];
Define Zipcode /
style=[borderrightwidth=1pt]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=graybb
borderrightwidth=1pt
borderrightcolor=black
background=greybb
just=c
vjust=c]
style(Column)=[
CellWidth=0.70in
borderrightwidth=1pt
borderrightcolor=black] CENTER;
run;
ODS TAGSETS.RTF close;
data one;
infile "~/zipcode.rtf" missover length=l end=eof lrecl=2000;
input line $varying2000. L;
retain n 0;
if index(line, '**') > 0 then do; n=0; line=tranwrd(line, '**', ''); end;
else do; n=n+1; end;
if n=1 then do; line=tranwrd(line, '\clbrdrb\brdrs', '');
end;
run;
data _null_; set one;
file "~/zipcode2.rtf";
put line;
run;
Hi @mcook ,
There is no medicine for the cure of this complication. A surgery is needed. I use your program and a different dataset zipcode from SASHELP, and ODS TAGSETS.RTF. See the attached code.
Jianmin Long
data zipcode; set sashelp.zipcode;
keep statename city zip countynm;
proc sort data=zipcode;
by statename countynm city zip;
data zipcode; set zipcode;
by statename countynm city zip;
length zipcode $10;
zipcode=compress(put(zip, 10.0));
if last.city=0 then do; zipcode=compress(put(zip, 10.0))||'**'; end;
run;
ODS TAGSETS.RTF file="~/zipcode.rtf";
ODS escapechar='^';
options nodate nonumber;
proc report data=zipcode spanrows split='~'
style(Header)=[just=l background=white]
Style(Report) = [Rules=Rows Frame=below];
Column ('^{Style[FontSize=12pt font_face="Times New Roman"]Table 3.2 This is my Table Title}'(Statename Countynm City Zipcode));
Define statename / group
style(column)=[
cellwidth=1.6in
Vjust=C]
style(header)=[
background=greybb
just=c
vjust=c] center;
Define countynm / Display 'County Name'
order order=internal
style(Column)=[
borderleftwidth=1pt
just=c vjust=c]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=graybb
background=graybb
just=c
vjust=c] CENTER;
Define City / order order=internal
style(Column)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=black
just=c vjust=c]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=black
borderrightwidth=1pt
borderrightcolor=black
background=greybb
just=c
vjust=c];
Define Zipcode /
style=[borderrightwidth=1pt]
style(Header)=[
borderleftwidth=1pt
borderleftcolor=graybb
borderrightwidth=1pt
borderrightcolor=black
background=greybb
just=c
vjust=c]
style(Column)=[
CellWidth=0.70in
borderrightwidth=1pt
borderrightcolor=black] CENTER;
run;
ODS TAGSETS.RTF close;
data one;
infile "~/zipcode.rtf" missover length=l end=eof lrecl=2000;
input line $varying2000. L;
retain n 0;
if index(line, '**') > 0 then do; n=0; line=tranwrd(line, '**', ''); end;
else do; n=n+1; end;
if n=1 then do; line=tranwrd(line, '\clbrdrb\brdrs', '');
end;
run;
data _null_; set one;
file "~/zipcode2.rtf";
put line;
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 25. 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.