f



"proc report" using a "by" variable as an "across" variable

I didn't know that you could use a "by" variable as an "across"
variable as well in proc report. I tried it out today just to see what
syntax errors it would throw at me but instead it worked without
complaint. I guess it's one of the things I should know but have never
come across before. It is useful for putting what would normally be in
a "by line" in the columns of a table instead. It looks better that
way, sometimes.

0
rolandberry (1870)
10/18/2005 11:38:07 AM
comp.soft-sys.sas 142828 articles. 2 followers. Post Follow

1 Replies
346 Views

Similar Articles

[PageSpeed] 47

On Tue, 18 Oct 2005 04:38:07 -0700, RolandRB <rolandberry@HOTMAIL.COM>
wrote:

>I didn't know that you could use a "by" variable as an "across"
>variable as well in proc report. I tried it out today just to see what
>syntax errors it would throw at me but instead it worked without
>complaint. I guess it's one of the things I should know but have never
>come across before. It is useful for putting what would normally be in
>a "by line" in the columns of a table instead. It looks better that
>way, sometimes.

Hiya

I am not sure I understand what you are saying.
Why would you want to use a by variable as an across variable as well?

You can use a BY variable as an ACROSS variable as well, but unless you
just want 1 column for the across variable, it does not make sense.
You will not get an error. If you want to see the variable within the
report, then there is no sense in defining it as an ACROSS variable.

Proc Report will produce a new report for each set of BY variables.

I use ACROSS variables quite extensively, as that makes the production of
some reports much simpler.

Run the sample code below and you can see the different results.

proc format;
value jj
  4 = "One"
  5 = "Two"
  6 = "Three"
  7 = "Four"
  ;
run;

data aa;
do i=1 to 5;
  do j=4 to 7;
     k=56;
  dummy=1;
   output;
   end;
end;
run;

proc sort;
by i j;
run;

options nobyline;

title "First run: I=#byval(i), J=#byval(j)";

proc report data=aa nowd headskip headline split="|";
by i j; /* Run 1 */
column k j,dummy;
define k /group "Key| " width=6;
define j/across " " format=jj. order=internal;
define dummy/sum " ";
quit;

title "Second run: I=#byval(i)";

proc report data=aa nowd headskip headline split="|";
by i ;  /* Run 2 */
column k j,dummy;
define k /group "Key| " width=6;
define j/across " " format=jj. order=internal;
define dummy/sum " ";
quit;
0
tom.hide1 (89)
10/19/2005 7:45:38 AM
Reply: