Date: Tue, 21 Apr 2009 15:57:24 -0400
Reply-To: Jonathan Goldberg <jgoldberg@BIOMEDSYS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jonathan Goldberg <jgoldberg@BIOMEDSYS.COM>
Subject: Re: Proc tabulate issue
Vikas:
One problem is that the code line:
>%if diff lt -5 %then %do;
needs to be
>%if &diff lt -5 %then %do;
so that you test the value of the macro parameter, rather than its name.
Jonathan
On Sun, 19 Apr 2009 23:22:59 -0700, chumba <vikas.dharamsattu@GMAIL.COM>
wrote:
>Hi,
>
>I am new to proc tabulate and have hit a stonewall.
>
>Here is my data,
>
>month year wt_sr unwt_sr diff
>4 2006 53.34176824 75.79526754 -22.4534993
>5 2006 51.17540713 75.01186216 -23.83645503
>6 2006 51.48527152 75.31043793 -23.82516641
>7 2006 49.13403917 75.31033179 -26.17629262
>8 2006 46.14089367 75.83825611 -29.69736244
>
>I need to color the cells in pdf format such that,
>
>if diff < -5 then wt_sr column should be red
>else if diff > 5 then wt_sr column should be yellow.
>
>Here is what I have tried so far,
>
>goptions device=sasprtc targetdevice=sasprtc;
>goptions reset=global gunit=pct
> htitle=4 htext=2 ftitle=zapfb ftext=swiss;
>goptions reset=global gunit=pct border cback=white
> colors=(blue green brown yellow black) ftitle=swissb
> ftext=swiss htitle=4 htext=2
> offshadow=(1.5,1.5);
>
>%macro test;
>
>data _null_;
>set vik.new;
>call symput('diff',diff);
>run;
>
>%put &diff.;
>
>ods pdf file="/aodev/vik/color/test.pdf"
> startpage=never;
>
>
>proc tabulate data=vik.new
> missing
> contents="Six Months Summary" style=[background=beige];
>class month /style={background=maroon
> foreground=white
> font_size=2
> just=left};
>
>class year /style={background=maroon
> foreground=white
> font_size=2
> just=left};
>
>var wt_sr / style=[background=lightgreen
> foreground=black];
>var unwt_sr / style=[background=lightcyan
> foreground=black];
>var diff / style=[background=lightyellow
> foreground=black];
>
>
>%if diff lt -5 %then %do;
>
>table month * [style=<parent>],
>year='Per Year' * (wt_sr='Weighted SR' * sum='' * f=comma9.0
> * [style=
>[background=red]]
> unwt_sr='Unweighted SR' * sum='' * f=comma9.0
> * [style=
>[background=lightcyan]]
> diff ='Difference' * [style=<parent>]);
>%end;
>
>%else %if diff gt 5 %then %do;
>
>table month * [style=<parent>],
>year='Per Year' * (wt_sr='Weighted SR' * sum='' * f=comma9.0
> * [style=
>[background=yellow]]
> unwt_sr='Unweighted SR' * sum='' * f=comma9.0
> * [style=
>[background=lightcyan]]
> diff ='Difference' * [style=<parent>]);
>
>%end;
>%else %do;
>table month * [style=<parent>],
>year='Per Year' * (wt_sr='Weighted SR' * sum='' * f=comma9.0
> * [style=
>[background=white]]
> unwt_sr='Unweighted SR' * sum='' * f=comma9.0
> * [style=
>[background=lightcyan]]
> diff ='Difference' * [style=<parent>]);
>
>%end;
>run;
>
>ods pdf close;
>
>%mend test;
>%test;
>
>In the output the above program seems to fulfill the diff > 5
>condition to be true eevn though all diff are < -5,
>and a result the all wt_sr cells are yellow.
>
>I am at my wits end with this one, could anyone please help me with
>this, would really appreciate it.
>
>Thanks in advance.
|