sasproc-report

SAS Proc Report Specific Setup


I want to use proc report to build a display instead of simple proc print. My data look like this.

A      B            C      D
Bill   Harry        Bog    The
Bill   Harry        Hog    Quick
Bill   Harry        Log    Brown
Bill   Hermione     Bog    Fox
Bill   Hermione     Hog    Jumps
Bill   Hermione     Log    Over
Bill   Ron          Bog    The
Bill   Ron          Hog    Lazy 
Bill   Ron          Log    Dogs
Ted    Harry        Bog    Peter
Ted    Harry        Hog    Piper
Ted    Harry        Log    Picked
Ted    Hermione     Bog    A
Ted    Hermione     Hog    Powerful
Ted    Hermione     Log    Peck
Ted    Ron          Bog    Of
Ted    Ron          Hog    Picked
Ted    Ron          Log    Peppers

And I want the final output to look like this:

A      B           Bog      Hog      Log
Bill   Harry       The      Quick    Brown
       Hermione    Fox      Jumps    Over
       Ron         The      Lazy     Dogs

Ted    Harry       Peter    Piper    Picked
       Hermione    A        Powerful Peck
       Ron         Of       Pickled   Peppers

All variables are character.

How do I set it up in proc report? I get close with the various combinations of group, across, etc, but I never seem to get this exactly. I'm a novice to proc report, any help appreciated.


Solution

  • Next time post your tried Proc REPORT code so we can get an idea of how you are thinking.

    Use the comma operator to stack columns c & d and a hidden statistic to force the stacking.

    proc report data=foo;
      columns a b c,d n;
      define a / group;
      define b / group;
      define c / across;
      define d / display;
      define n / noprint;
    run;
    

    Recommended reading: Sailing Over the ACROSS Hurdle in PROC REPORT. Cynthia L. Zender, SAS Institute Inc., Cary, NC