arrayssasproc-report

How to use arrays in proc report?


I am trying to replicate the arrays in proc report from this example in a simpler but slightly different way, and I can't make it work. I keep changing things and a lot of times it removes the errors I was getting but creates new errors. The code below runs without errors, but the style is not bold. Any idea how to fix the below code? Also is there any documentation on how to use arrays in proc report? I couldn't find any.

data x;
input cat $ biga bigb smaa smab meda medb;
cards;
meow 1 1 2 3 5 5
oops 9 9 2 2 5 1
;
run;

ods html;
proc report nowd data=x;
column cat -- medb dummy;
define dummy / computed noprint;
compute dummy;
    array avar(3) biga smaa meda;
    array bvar(3) bigb smab medb;
    do i = 1 to dim(avar);
        if avar(i) ^= bvar(i) then call define(bvar(i),'style','style=[font_weight=bold]');
    end;
endcomp;
run;
;quit;
ods html close;

Solution

  • Thanks PBulls, that was the solution, I was able to get it work by just adding the vname(). I didn't want to use column numbers because they could change as I add and remove columns. I didn't need to add the .sum part to the variable names.

    proc report nowd data=x;
    column cat -- medb dummy;
    define dummy / computed noprint;
    compute dummy;
        array avar(3) biga smaa meda;
        array bvar(3) bigb smab medb;
        do i = 1 to dim(avar);
            if avar(i) ^= vname(bvar(i)) then call define(bvar(i),'style','style=[font_weight=bold]');
        end;
    endcomp;
    run;
    ;quit;