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
Thank you for your consideration.
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.
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 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.