The following table is generated by this code.
Removing the bottom border for cells in the Compute blocks leaves a white gap in the vertical border. Any suggestions on how to remedy this?
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;
proc sort data=ClassTable;
by Sex Name Section;
run;
data ClassTable;
set ClassTable;
by sex name;
if last.Name=0 then
ID=1;
else ID=0;
run;
ods RTF file="&FilePath.\RowRemove.RTF";
options nonumber nodate;
proc report data=classtable spanrows
style(report)=[frame=hsides]
style(Column)=[VJust=C];
columns ID sex Name Section Age Height Weight;
define sex / display group center;
define name / display group center;
define section / display center;
define Age / display center;
define Height / display Center;
define Weight / display center;
define ID / display noprint;
compute Section;
if ID=1 then
call define (_col_,'style','style=[borderbottomcolor=white]');
endcomp;
compute Age;
if ID=1 then
call define(_Col_,'style','style=[borderbottomcolor=white]');
EndComp;
compute Height;
if ID=1 then
call define(_Col_,'style','style=[borderbottomcolor=white]');
EndComp;
Compute Weight;
if ID=1 then
call define(_Col_,'style','style=[borderbottomcolor=white]');
EndComp;
run;
ods rtf close;
When you use BORDERBOTTOMCOLOR=WHITE you are telling SAS to draw a white line which looks like a "gap".
Try instead using BORDERBOTTOMWIDTH=0.
This did what I think you want:
proc report data=classtable spanrows style(report)=[frame=hsides] style(Column)=[VJust=C]; columns ID sex Name Section Age Height Weight; define sex / display group center; define name / display group center; define section / display center; define Age / display center; define Height / display Center; define Weight / display center; define ID / display noprint; compute Section; if ID=1 then call define (_col_,'style','style=[borderbottomwidth=0]'); endcomp; compute Age; if ID=1 then call define(_Col_,'style','style=[borderbottomwidth=0]'); EndComp; compute Height; if ID=1 then call define(_Col_,'style','style=[borderbottomwidth=0]'); EndComp; Compute Weight; if ID=1 then call define(_Col_,'style','style=[borderbottomwidth=0]'); EndComp; run;
In some uses you may also have to work with other cell bordertopwidth or the left/right widths.
You want this ?
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;
proc sort data=ClassTable;
by Sex Name Section;
run;
data ClassTable;
set ClassTable;
by sex name;
if last.Name=0 then
ID=1;
else ID=0;
run;
ods RTF file="c:\temp\RowRemove.RTF" bodytitle ;
options nonumber nodate;
proc report data=classtable spanrows
style(header)=[borderbottomcolor=black borderbottomwidth=2px ]
style(report)=[ rules=cols]
style(Column)=[VJust=C];
columns ID sex Name Section Age Height Weight;
define sex / group center;
define name / group center;
define section / display center;
define Age / display center;
define Height / display Center;
define Weight / display center;
define ID / display noprint;
compute weight;
if id=0 then call define (_row_,'style','style=[borderbottomcolor=black borderbottomwidth=2px ]');
call define ('sex','style','style=[borderbottomcolor=black borderbottomwidth=2px ]');
call define ('name','style','style=[borderbottomcolor=black borderbottomwidth=2px ]');
endcomp;
run;
ods rtf close;
Hi @Ksharp ,
It's a very clever way to handle this request, and your program works nicely for a small dataset, in one page. The program would not work for a large dataset, ODS tagsets.rtf works better for a large dataset, see the code:
proc sort data=sashelp.zipcode out=zipcode(keep=timezone statename countynm city zip); by timezone statename countynm city zip; run; data zipcode; set zipcode; by timezone statename countynm city zip; *if _n_ le 400; if last.city then id=0; else id=1; run; ods tagsets.RTF file="~/sasout/RowRemove.RTF"; options nonumber nodate; proc report data=zipcode spanrows style(header)=[borderbottomcolor=black borderbottomwidth=2px ] style(report)=[ rules=cols] style(Column)=[VJust=C]; columns ID timezone statename countynm city zip; define timezone / group center; define statename / group center; define countynm / group center; define city / group center; define zip / display Center; define ID / display noprint; compute city; if id=0 then call define (_row_,'style','style=[borderbottomcolor=black borderbottomwidth=2px ]'); call define ('Timezone','style','style=[borderbottomcolor=black borderbottomwidth=2px ]'); call define ('statename','style','style=[borderbottomcolor=black borderbottomwidth=2px ]'); call define ('countynm','style','style=[borderbottomcolor=black borderbottomwidth=2px ]'); call define ('city','style','style=[borderbottomcolor=black borderbottomwidth=2px ]'); endcomp; run; ods tagsets.rtf close;
but it creates a rtf file that is not a Word document. That is, if you select a few rows in the column of City, and change the font size to a large number, say 24 points, then you can't read the city name very well, unless you also adjust the cell height, then that will break your table, in terms of pagination. This is because ODS tagsets.rtf uses an absolute cell height to control the vertical spaces to achieve correct pagination.
By the way, if you run the whole zipcode data, you will have an output of 1100+ pages, there must be a better way to create a zipcode book for about 100 pages. Think of a dictionary and an alternative for SPANROWS.
Many Thanks
Jianmin Long
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.