BookmarkSubscribeRSS Feed
bconner
Fluorite | Level 6

Hi,

 

I'm trying to produce a report which has the column titles just above each data row in an ordered input file.  In addition, I'm using a Line statement to show the value of the sorted variable, and wanted it the same color as tht titles across all rows, centered. 

 

What I have so far is:

 

ods escapechar='^';

proc report data=sashelp.baseball

style(header)={borderwidth=1 background=CXC0C0C0 just=c vjust=m font_weight=bold};

where team like 'S%';

 

column team name position salary;

 

define team / display order noprint f=$60.;

define name / display 'Player' f=$60.;

define position / display;

define salary / display;

 

compute before / style={color=white background=CX003366};

line "Test For Proc Report";

endcomp;

 

compute before team / style={just=left};

line 'Start of Season';

l='^S={background=CX003366 color=white just=c}Team '||team;

line '^S={background=CX003366 color=white just=c}' team $;

endcomp;

run;

 

in this example, the team titles show above the members of that team in white letters with a blue background.  I need to have the entire line blue and the team name centered without the other lines in that compute block centered.  Apparently the compute style overrides the embedded line style. 

 

I'd also like to be able to have the column titles between the team name and the rows of the players.  Is that possible?

 

Thanks!

 

--Ben

 

7 REPLIES 7
ballardw
Super User

Can you show an example of what this output should look like for two teams?

BenConner
Pyrite | Level 9

Would like to see something like this:

Capture.PNG

 

 

Ksharp
Super User
How about this one :


proc sort data=sashelp.baseball out=baseball;by team;run;
data have;
 set baseball;
 by team;
 where team like 'S%';
 if first.team then group+1;
run;

ods escapechar='^';
proc report data=have nowd noheader; 
column team group name position salary;
 
define group/ order noprint; 
define team / order noprint f=$60.;
define name / display 'Player' f=$60.;
define position / display style={cellwidth=4cm};
define salary / display style={cellwidth=4cm};
 
compute before _page_/ style={just=c color=white background=CX003366};
line "Test For Proc Report";
endcomp;

compute before/style={just=l};
line 'Start of Season';
endcomp;
 
compute before team/style(lines)={background=CX003366 color=white just=c} ;
line Team $20.;
endcomp;

compute before group
/style(lines)={borderwidth=1 background=CXC0C0C0 just=c vjust=m font_weight=bold} ;
line @2'Player' @22'Position(s) in 1986' @65'1987 Salary in $ Thousands';
endcomp;
run;
 


x.png
BenConner
Pyrite | Level 9

Interesting.  That's an approach I hadn't considered.  The only down side I see is trying to align the titles above the columns.  The actual project has the output going to an excel spreadsheet with the tagsets.excelxp destination.  Will see if there is a way to 'suggest' alignment information.

 

Thanks!

 

--Ben

Cynthia_sas
SAS Super FREQ
Hi, the LINE statement will NOT work the way you envision. All the @ sign controls are ignored by ODS destinations. Just FYI. I may have something similar -- I'll check when I'm on the other computer.
cynthia
Ksharp
Super User
OK. Try this one :






proc sort data=sashelp.baseball out=baseball;by team;run;
data have;
length name position new_salary $ 40;
 set baseball;
 by team;
 where team like 'S%';
 if first.team then group+1;
 new_salary=put(salary,best.-l);
 drop salary;
run;
ods tagsets.excelxp file='/folders/myfolders/x.xml';
ods escapechar='^';
proc report data=have nowd noheader
style(summary)={borderwidth=1 background=CXC0C0C0 just=c vjust=m font_weight=bold} ; 
column team group name position new_salary;
 
define group/ order noprint; 
define team / order noprint ;
define name / display 'Player';
define position / display ;
define new_salary / display style={just=right};
 
compute before _page_/ style={just=c color=white background=CX003366};
line "Test For Proc Report";
endcomp;

compute before/style={just=l};
line 'Start of Season';
endcomp;
 
compute before team/style={background=CX003366 color=white just=c} ;
line Team $20.;
endcomp;

compute before group;
name='Player';
position='Position(s) in 1986';
new_salary='1987 Salary in $ Thousands';
endcomp;

break before group/summarize;
run;
ods tagsets.excelxp close;
 



x.png
BenConner
Pyrite | Level 9

Ok, that's just plain slick. 🙂  Outstanding!

 

Thank you so much! It does exactly what I was looking for.  Just couldn't put it quite together.

 

This will help a lot on the actual project I'm working on.

 

--Ben

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 2092 views
  • 1 like
  • 5 in conversation