BookmarkSubscribeRSS Feed
mmea
Quartz | Level 8

Hi. 

I have the following code for a proc report. 

I have stated that I want some colors, but they do not show in the expected output. 

Also I have shown the ouput below - I want to remove the row with the "ventetid" labels - is that possible?

%macro many_col;
    proc sql noprint;
        select distinct dato into :ncols from pdf1;
    quit;
proc format;
    value pctf .=' ' low-<0.1='<10%' 0.1-high='>10%';
    value colorf .=white low-<0.1=lightmoderatered 0.1-high=Steel;
run;
proc report data=pdf1;
    columns region teststed dato, ventetid;
    define region/group;
    define teststed/group;
    define dato/across order=internal format= ddmmyyd10.;
    define ventetid/sum format=pctf5.;
    compute ventetid;
          %do i=1 %to &ncols;
               call define("_c%eval(&i+2)_",'style','style={background=colorf.}');
          %end;
      endcompute;
	  
run;
%mend;

%many_col

mmea_1-1608490579770.png

Also is it possible in the proc report code to divide the variable "teststed" up in two other groups that will be based on the observations under "teststed" - so e.g. if "teststed" includes something with XXXX then put it in under a new label called "EXAMPLE" etc. So basically under each "region" i want two groups of variables with matching observations.

 

hope it makes sense 🙂

3 REPLIES 3
PaigeMiller
Diamond | Level 26

There's no need to put this in a new thread, when it is truly a continuation of the other thread. MODERATORS, please merge this with the other thread.

--
Paige Miller
Ksharp
Super User

Include style in proc format.

 

proc format;
    value pctf 
      .=' ~S={background=white}' 
     low-<0.1='~S={background=lightmoderatered } <10%' 
      0.1-high='~S={background=green } >10%';
run;
ods escapechar='~';
proc report data=pdf1 nowd;
    columns region teststed dato, ventetid;
    define region/group;
    define teststed/group;
    define dato/across order=internal format= ddmmyyd10.;
    define ventetid/sum format=pctf60.;  
run;
Cynthia_sas
Diamond | Level 26

Hi:

  I do not believe this requires a SAS macro program or CALL DEFINE or using ODS ESCAPECHAR. This works for me with a simple format, specified correctly and a single style override in the DEFINE statement for HEIGHT and WEIGHT:

Cynthia_sas_0-1608569504724.png

Hope this gives you some idea of the most straightforward way to use a format and a style override with PROC REPORT to color cells.

Cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1108 views
  • 1 like
  • 4 in conversation