tags:

views:

319

answers:

1

I am working on a report in Base SAS 8.1(OpenVMS). I need it to have 1 page per observation...similar to below. I can't find anything that shows how to do this with PROC PRINT or PROC REPORT. Is there any way to do this other than with the PUT statement? Upgrading or adding modules isn't an option unfortunately. Any help is appreciated.

Header Text Observation ID 1

Line 1 text ---------------- variable 1

Line 2 text ---------------- variable 2

Line 3 text ---------------- variable 3

--page break --

Header Text Observation ID 2

Line 1 text ---------------- variable 1

Line 2 text ---------------- variable 2

Line 3 text ---------------- variable 3

--page break --

+5  A: 

If you transpose the dataset by the observation number, then proc report can handle it with no problem. hth.

/* test data -- each obs is identified by obsId */
data class;
  set sashelp.class;
  obsId = _n_;
run;

/* transpose the data */
proc transpose 
  data=class 
  out=report(rename=(_name_=var col1=value));
  var _all_;
  by obsId;
run;

/* change the varaible name into "Line 1 text ..." */
data report;
  drop line cLine dashes;
  length var cLine $30;
  dashes = repeat("-", 20-1);
  /* usual DoW */
  do line = 1 by 1 until (last.obsId);
    set report;
    by obsId;
    cLine = put(line, best.-l);
    var = "Line "||trim(cline)||" text "||dashes;
    output;
  end;
run;

/* print out one obs per page */
options nocenter;
proc report data=report nowd;
  column obsId var value;
  define obsId / " " group noprint;
  define var / " " display left;
  define value / " " display left;
  break after obsId / page;
  compute before obsId;
    id = put(obsId, best.-l);
    len = length(id);
    line @2 "Header Text Observation Id " iD $varying. len;
    line " ";
  endcomp;
run;

/* on lst, in part. 
Header Text Observation Id 1

 Line 1 text ------------------  Alfred
 Line 2 text ------------------  M
 Line 3 text ------------------            14
 Line 4 text ------------------            69
 Line 5 text ------------------         112.5
 Line 6 text ------------------             1

(new page)
Header Text Observation Id 2

 Line 1 text ------------------  Alice
 Line 2 text ------------------  F
 Line 3 text ------------------            13
 Line 4 text ------------------          56.5
 Line 5 text ------------------            84
 Line 6 text ------------------             2

(new page)
...
*/
Chang Chung
Thanks. I will check this out. I have never used proc transpose before.
Dan Adams