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

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)

 

InkedCapture_LI.jpg

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jianmin
Obsidian | Level 7

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; 

 

View solution in original post

2 REPLIES 2
Jianmin
Obsidian | Level 7

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; 

 

mcook
Quartz | Level 8
That's quite a tedious pain in the SAS if theres more than one variable to remove the row line from. but it does work. Thank you immensely.

The only downside i see is that I am now running the report on all character variables, and am unable to apply a numeric format. Is there a way to revert certain variables back to numeric and apply a format in that final data step?

data _null_; set one;
file "&FilePath./TestRTF2.rtf";
put line;
run;


sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 508 views
  • 0 likes
  • 2 in conversation