highlight the report

Reply
Occasional Contributor
Posts: 18

highlight the report

Hi everyone,

Can some body help me to resolve this problem;

  I have a followinf data;

               name     x     y     z

               john         12     23     45

               john           12     10     56

               jenny          10     23     23

               jenny          12     56     64

Highlight even row of x if odd row of x>20;

highlight even row of y if odd row of y>20

highlight even row of z if od row of z>20.

Your help is highly appreciated.

Ram Adhikari

              

         

         











Super User
Posts: 17,840

Re: highlight the report

We need more info and I don't feel like guessing.

1. What's your destination, ie excel, pdf, rtf?

2. You say even/odd what are you references, by name? is that the same as first and last or can you have multiple of each name, e.g can you have 3 or 1 of a name?

3. Is it simply highlight the row, or don't highlight if it doesn't meet the condition? How will you tell why the row was highlighted? Is it simply if any of the 3 are over 20 in the previous row.

4. Are you highlighting the whole row or just that cell really?

Here's a reference that can help...

http://support.sas.com/resources/papers/proceedings11/170-2011.pdf

Occasional Contributor
Posts: 18

Re: highlight the report

Dear Reeza,

Sorry for incomplete info. Would this information better help you understand more.

my destination is rtf

even/odd reference by name

I have two observations for each name

I just want to highlight cell not the complete row.

Thanks for your co-operation

Ram

SAS Super FREQ
Posts: 8,743

Re: highlight the report


Hi:

  I don't quite understand what you mean. First, what is your desired output? You cannot highlight in a data table, so you must want a report? If you want a report, what kind of output do you want? HTML, RTF? PDF?

  Next, you say you want to "highlight" -- how do you want to highlight? Make the background yellow? Make the font color red? make the background cyan and the font color purple?

  Also, I don't quite understand what you mean by "Highlight even row of x if odd row of x>20" -- you show 4 rows, 2 for john and 2 for jenny. Can you explain which rows in your sample data would be highlighted and how they would be highlighted? Would you want the whole row highlighted? Or just the X column or the Y column or the Z column??

  And, what about the data -- will you ALWAYS have 2 rows for each person? Could there ever be 3 rows for one person and 5 rows for another person? Does every person get treated as 1 group?

  The program below produced the attached output. Notice how the row for Alice is different, depending on whether she starts a separate group or not. This is the kind of thing that can happen if you don't have exactly the same number of rows per person. The TYPE variable is on the report just to show how ODD/EVEN can be different depending on the criteria you set. The program also shows how to do highlighting based on a report variable, just a row is highlighted in #1, but other conditions are highlighted in #2 report.

cynthia

proc sort data=sashelp.class out=class;
  by age name;
  where age in (12, 13);
run;

ods listing close;
 
ods html file='c:\temp\evenodd.html';

proc report data=class nowd;
  title '1) Age is Ordering Variable';
  column type age name sex height weight;
  define type / computed f=$4.;
  define age /order;
  define name / order;
  define sex / display;
  define height / display;
  define weight / display;
  compute type / character length=4;
    cntr+1;
    if mod(cntr,2) = 0 then type = 'even';
    else type = 'odd';
  endcomp;
  compute name;
    if name = 'Alice' then
       call define(_row_,'style','style={background=yellow}');
  endcomp;
run;

proc report data=class nowd;
  title '2) Same Order to variables';
  title2 'But start Counter to 1 for each gender';
  column type age name sex height weight;
  define type / computed f=$4.;
  define age /order;
  define name / order;
  define sex / display;
  define height / display;
  define weight / display;
  compute before age;
    cntr = 0;
  endcomp;
  compute type / character length=4;
    cntr+1;
    if mod(cntr,2) = 0 then type = 'even';
    else type = 'odd';
  endcomp;

  compute name;

    if name = 'Alice' then

       call define(_row_,'style','style={background=yellow}');

  endcomp;

  compute height;

    if height gt 60 then

       call define(_col_,'style','style={background=cyan}');

  endcomp;

  compute weight;

    if weight lt 100 and height gt 60 then do;

       call define(_col_,'style','style={background=pink}');

       call define('height','style','style={background=pink}');

    end;

  endcomp;

run;
ods html close;


highlight_row.png
Ask a Question
Discussion stats
  • 3 replies
  • 228 views
  • 0 likes
  • 3 in conversation