BookmarkSubscribeRSS Feed
amar8580
Calcite | Level 5

hi all 

i am new to sas and using SAS EG

i am trying to do two things using proc report

my data is following

h1 | rgu

sales | 700

wow | .5

what i want to do is format alignment of h1 column that if value is sales then align to right, if value is wow then align h1 column to left.

also i am able to change the wow rgu value to percent but how do i color it to red if negative and green if positive.

any suggestions would help

2 REPLIES 2
TomKari
Onyx | Level 15

Hi, and welcome to the SAS community!

 

PROC REPORT is an amazing tool, but to be honest it's a challenge for new users. I've just climbed that learning curve because of a new project.

 

I'm pretty sure what you want can be fairly easily done using PROC REPORT, and probably not with anything else, but I don't have the time to go through the trial-and-error to figure it out.

 

I'm pretty sure you'll want to use the STYLE features in PROC REPORT. I can suggest two things:

 

This link show an example of using PROC REPORT to change style elements; in particular, check out the "compute sales" block, where the characteristics of data are used to change the style of the cell.

 

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000545547.htm

 

 The other thing I do is google furiously for the result I'm trying to get. There are some amazing papers out there where PROC REPORT experts show how to accomplish these tasks.

 

One last comment; I'm fairly sure you won't be able to get your result using the "List Report" task, you'll most likely have to write SAS code to do this.

 

Good luck!

   Tom

 

Ksharp
Super User

You should post it at ODS and Base Reporting

 

 

data have;
input h1 $ rgu;
cards;
sales   700
wow   .5
wwe   -.5
;
run;

proc format;
value fmt
 low-<0='red'
 0-high='green';
run;



proc report data=have nowd;
columns h1 rgu;
define h1/display style={cellwidth=40};
define rgu/display style={backgroundcolor=fmt.};
compute h1;
 if h1='sales' then call define(_col_,'style','style={just=right}');
endcomp;
run;

x.png

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 851 views
  • 0 likes
  • 3 in conversation