BookmarkSubscribeRSS Feed
Diego_C
Calcite | Level 5

Hello,

I have a pretty simple report where I put an X on the buildings that are missing. The x is a format and the variable ind_manq is really a 1 or a 0 (missing building). I also want it to be red when there's an X but I can't seem to get the coulour working. My data set is just a list of buildings, the fiscal period we're in and the ind_manq variable.

/*Exportation EXCEL*/

OPTIONS NODATE NONUMBER MISSING=" " orientation=landscape papersize=LEGAL;


ods excel file="Directory\.xlsx" 
   options(suppress_bylines="yes"
           sheet_name="Sheet"
           embedded_titles="yes"
		   embedded_footnotes="yes"
	   	   frozen_headers="yes");

PROC REPORT DATA= mylib.mydata nowd split="|" spanrows STYLE(HEADER)=angle_header;
	options missing="";
	COLUMN nomRegion nomEtabl n=cntage ind_manq2 ind_manq;
	DEFINE  nomRegion / group "Region" STYLE(column)={JUST=L cellwidth=2.0in};
	DEFINE  nomEtabl / order "Établissement" STYLE(column)={JUST=L cellwidth=2.0in};
	DEFINE cntage / noprint;
	DEFINE ind_manq2 / noprint;
	DEFINE  ind_manq / "&PER_V." STYLE(column)={JUST=R cellwidth=1.0in} format=ixs.;

	compute ind_manq;
		if ind_manq=0 then call define (_COL_, "style", "style=[background=red]");
	endcomp;

rbreak after /summarize;
compute after;
ind_manq = "Total remplis";
endcomp;


	title "Title";
	title2 "Extraction effectuée en date du &date.";
	footnote bold height=16pt COLOR=red J=C "DOCUMENT DE TRAVAIL"; 
run;

Here's an image of my table
The cell with the x should be redThe cell with the x should be red

 

Thank you for your consideration.

2 REPLIES 2
ballardw
Super User

Example data in the form of a working data step will let us test the code.

Definition of the format IXS would help as well.

 

 

ballardw
Super User

Here is an example of using one format to display given text for a range of values and then color the cell based on the same range of values. You should be able to run this code as the SASHELP.CLASS data set is provided by SAS as a training set.

proc format library=work;
value heightgrp
100 - high = '+'
other = ' '
;
value backcolor
100 - high = 'red'
other = ''
;


proc report data=sashelp.class;
   columns sex age height;
   define sex/ group;
   define age/ group;
   define height/ format=heightgrp. style={cellwidth=1.in backgroundcolor=backcolor.};
run;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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