BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data have;

infile datalines;

input Teammate $ Area Branch $ Opened Inactive ;

return;

datalines;

 

Richardson 17500 Sims 52 2

Richardson 17522 Heigth 62 2

Shaw 17500 Sims 22 6

Richardson 17500 Sims 120 1

Shaw 1500 Hamphire 12 1

James 17500 Sims 50 40

Phelps 17500 Handley 12 6

;run;

Proc Report data = have NOWD Wrap style(summary)=Header;

column Teammate Area Branch Opened Inactive pct_inact ;

define Teammate /group style(column)=[cellwidth=100pt] "Teammate";

define Area / group style (column)=[cellwidth=100pt] "Center";

define Branch /group style(column)=[cellwidth=90pt];

define Opened / sum style(column)=[cellwidth=90pt] 'Total Opened For Period: ' ;

define Inactive / sum style(column)=[cellwidth=90pt] 'Total Inactive For Period: ' ;

define pct_inact /computed f=percent8.2 "%Inactive for preiod" style(column)=[cellwidth=90pt];

compute pct_inact;

pct_inact =_c5_ / _c4_; /*total% inactive*/

endcomp;

rbreak after / summarize style (summary)= Header;

compute after;

Teammate = 'Total';

endcomp;

run;

 

When running the code why am I NOT getting all of the Teammates(first column)??  The 4th and 6th columns are blank.  The report is to be based on Teammate

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

When I run your code, I am not seeing the 4th and 6th columns as blank. They have numbers in them.

 

Teammate Center Branch Total Opened For Period: Total Inactive For Period: %Inactive for preiod
James 17500 Sims 50 40 80.00%
Phelps 17500 Handley 12 6 50.00%
Richards 17500 Sims 172 3 1.74%
  17522 Heigth 62 2 3.23%
Shaw 1500 Hamphire 12 1 8.33%
  17500 Sims 22 6 27.27%
Total     330 58 17.58%
--
Paige Miller
Q1983
Lapis Lazuli | Level 10

Exactly, my question was, why are we not seeing the name of the Teammate populated?  What must I do with proc report to get the actual Teammate name to display??

ed_sas_member
Meteorite | Level 14

Hi @Q1983 

Here is a way to handle that (cf. compute bloc). 

I have also added the %nrstr() function to mask the % in your label and avoid a warning in the log.

NB: all rows were not populated with the name of the Teammate because it is defined as a GROUP variable in the DEFINE statement.

This group allow to compute summary statistics so it is a better way to display the report

 

 

proc report data=have NOWD Wrap style(summary)=Header;
	
	column Teammate Area Branch Opened Inactive pct_inact;
	
	define Teammate /group style(column)=[cellwidth=100pt] "Teammate";
	define Area / group style (column)=[cellwidth=100pt] "Center";
	define Branch /group style(column)=[cellwidth=90pt];
	define Opened / sum style(column)=[cellwidth=90pt] 'Total Opened For Period: ';
	define Inactive / sum style(column)=[cellwidth=90pt] 'Total Inactive For Period: ';
	define pct_inact /computed f=percent8.2 %nrstr("%Inactive for period") style(column)=[cellwidth=90pt];

	rbreak after / summarize style (summary)=Header;
	
	compute pct_inact;
		pct_inact=_c5_ / _c4_; /*total% inactive*/
	endcomp;
	
	compute Teammate;
		if Teammate NE ' ' then hold=Teammate ;
		if Teammate EQ ' ' then Teammate=hold ;
	endcomp;
	
	compute after;
		Teammate='Total';
	endcomp;

run;

 

PaigeMiller
Diamond | Level 26

I have also added the %nrstr() function to mask the % in your label and avoid a warning in the log.

 

You could also just change the double-quotes to single quotes.

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 544 views
  • 3 likes
  • 3 in conversation