options ls=90 ps=40;
title1 'First title';
title3 'Third title';
title5 'Fifth title';
footnote1 'First footnote';
footnote3 'Third footnote';
/*--------------------------------------------------*
Generate the dummy data
*--------------------------------------------------*/
data test;
length sex $ 6 param $ 80 race $ 10;
subj=1001;invid=10001;age=21;race='Asian';sex='Male';weight=60;
param='AA This is a very long parameter and you will have
to flow it';
value=11;output;
param='BB This is a short parameter';
value=21;output;
value=22;output;
param='CC This is a very long parameter and you will have
to flow it';
do value=30 to 38;
output;
end;
subj=2001;invid=20001;age=32;race='White';sex='Female';weight=55;
param='AA This is a very long parameter and you will have
to flow it';
value=51;output;
param='BB This is a short parameter';
value=61;output;
value=62;output;
param='CC This is a very long parameter and you will have
to flow it';
do value=70 to 78;
output;
end;
subj=3001;invid=30001;age=42;race='Black';sex='Female';weight=65;
param='AA This is a very long parameter and you will have
to flow it';
value=51;output;
param='BB This is a short parameter';
value=61;output;
run;
/*--------------------------------------------------*
Produce the report
*--------------------------------------------------*/
data _null_;
length tempstr $ 200;
retain ls 0 startcol 0 repwidth 60 count 0;
file print titles footnotes header=header linesleft=ll;
set test end=last;
by subj param;
if _n_=1 then do;
ls=getoption('ls');
startcol=floor((ls-repwidth)/2)+1;
end;
if ll<2 then put _page_;
if first.subj then do;
count=0;
if ll<5 then put _page_;
end;
count=count+1;
%splitvar(param,38,split='*');
link flow;
if first.param or count=1 then do;
tempstr=scan(param,1,'*');
put @startcol+18 tempstr @startcol+57 value
4.;
i=2;
do while(scan(param,i,'*') NE ' ');
count=count+1;
link flow;
tempstr=scan(param,i,'*');
put @startcol+18 tempstr;
i=i+1;
end;
end;
else put @startcol+57 value 4.;
if last.param then do;
count=count+1;
link flow;
if not last or count<5 then put;
end;
if last.subj then link lastsubj;
return;
header:
put;
put @startcol '
age/';
put @startcol '
race/';
put @startcol 'subject/ sex/';
put @startcol 'invid. weight Lab
parameter
value';
put @startcol '--------------------------------------------------------------';
if _n_ ne 1 then count=0;
return;
flow:
if count=1 then put @startcol subj 6. '/' @startcol+8 age
2. ' yrs/' @;
else if count=2 then put @startcol invid 6. @startcol+8
race $char6. +(-1) '/' @;
else if count=3 then put @startcol+8 sex $char6. '/'
@;
else if count=4 then put @startcol+8 weight 3. ' kg' @;
return;
lastsubj:
if count<4 then do;
do count=(count+1) to 4;
link flow;
put;
end;
if not last then put;
end;
return;
run; |