SAS Report

Accepted Solution Solved
Reply
Contributor
Posts: 48
Accepted Solution

SAS Report

Dear All,

I have a data set like  below

data dsn;infile datalines dsd dlm=',';

input order DIALYZER$ Total_ $ Total $ Total1 $ Atleast_ $ Atleast $  Atleast1 $  ;

1,OVERALL,Total,Total,Total,Atleast,Atleast,Atleast


1,OVERALL,Total,Major,Minor,Atleast,Major,Minor


1,OVERALL,Total,0,20,Atleast,0 (0.00%),12 (60.00%)


2,A,Total,Total,Total,Atleast,Atleast,Atleast


2,A,Total,Major,Minor,Atleast,Major,Minor


2,A,Total,0,6,Atleast,0 (0.00%),6 (31.58%)


3,B,Total,Total,Total,Atleast,Atleast,Atleast


3,B,Total,Major,Minor,Atleast,Major,Minor


3,B,Total,0,4,Atleast,0 (0.00%),4 (20.00%)


4,C,Total,Total,Total,Atleast,Atleast,Atleast


4,C,Total,Major,Minor,Atleast,Major,Minor


4,C,Total,0,5,Atleast,0 (0.00%),5 (26.32%)


5,D,Total,Total,Total,Atleast,Atleast,Atleast


5,D,Total,Major,Minor,Atleast,Major,Minor


5,D,Total,0,5,Atleast,0 (0.00%),5 (26.32%)

;

run;

PROC report data = dsn  nowd style(header)= [background=white]  split = '*'  headline headskip ;


column  ("Table 14.1.3*Descriptive Summary of Protocol Deviations" order  DIALYZER  Total Total1 Atleast Atleast1 );



define DIALYZER/ group  order '' ;


define order/order '' noprint ;     


define DIALYZER/ center  style(column)={cellwidth=3.0in} noprint;


define Total/ center  ' ' style(column)={cellwidth=1.5in} ;


define Total1/ center '' style(column)={cellwidth=1.5in} ;


define Atleast/ center  ' ' style(column)={cellwidth=1.5in} ;


define Atleast1/ center ' ' style(column)={cellwidth=1.5in} ;

compute before DIALYZER;

Line  ' ';

LINE  DIALYZER $;

endcomp

;quit;

I need to  show output for each group in DIALYZER, in each box(not in each page) instead of all the groups in single box.

Many Thanks In Advance.


Accepted Solutions
Solution
‎06-20-2015 02:48 AM
Super User
Posts: 9,687

Re: SAS Report

How about this :

data dsn;
infile datalines dsd dlm=',';
input order DIALYZER$ Total_ $ Total $ Total1 $ Atleast_ $ Atleast $  Atleast1 $  ;
cards;
1,OVERALL,Total,Total,Total,Atleast,Atleast,Atleast
1,OVERALL,Total,Major,Minor,Atleast,Major,Minor
1,OVERALL,Total,0,20,Atleast,0 (0.00%),12 (60.00%)
2,A,Total,Total,Total,Atleast,Atleast,Atleast
2,A,Total,Major,Minor,Atleast,Major,Minor
2,A,Total,0,6,Atleast,0 (0.00%),6 (31.58%)
3,B,Total,Total,Total,Atleast,Atleast,Atleast
3,B,Total,Major,Minor,Atleast,Major,Minor
3,B,Total,0,4,Atleast,0 (0.00%),4 (20.00%)
4,C,Total,Total,Total,Atleast,Atleast,Atleast
4,C,Total,Major,Minor,Atleast,Major,Minor
4,C,Total,0,5,Atleast,0 (0.00%),5 (26.32%)
5,D,Total,Total,Total,Atleast,Atleast,Atleast
5,D,Total,Major,Minor,Atleast,Major,Minor
5,D,Total,0,5,Atleast,0 (0.00%),5 (26.32%)
;
run;
proc sort data=dsn;by order DIALYZER ;run;
ods html file='c:\temp\x.html'  options(pagebreak='no') style=sasweb ;
options nobyline;
ods escapechar='~';
ods text="~S={fontweight=bold fontsize=.5cm }%sysfunc(repeat(~_,48))Table 14.1.3*Descriptive Summary of Protocol Deviations" ;
title1 ' ';
title2 "#byval2";
PROC report data = dsn  nowd noheader ;
by order DIALYZER ;
column    Total Total1 Atleast Atleast1 ;
define Total/ center  ' ' style(column)={cellwidth=1.5in} ;
define Total1/ center '' style(column)={cellwidth=1.5in} ;
define Atleast/ center  ' ' style(column)={cellwidth=1.5in} ;
define Atleast1/ center ' ' style(column)={cellwidth=1.5in} ;
;quit;
ods html close;

x.png

Xia Keshan

View solution in original post


All Replies
Super User
Posts: 10,535

Re: SAS Report

It would help if you built a table manually from your example to show what you intend for the output as "in each box( not in each page)" isn't obvious for what you want.

Super User
Posts: 9,687

Re: SAS Report

Post it at ODS and Base Reporting  ,Cynthia is there .

SAS Super FREQ
Posts: 8,743

Re: SAS Report

Hi:

  I see some problems/issues in your code:

1) you do not specify your destination of interest -- RTF, PDF, HTML? You use HEADLINE and HEADSKIP, which are LISTING only options and ignored by ODS. But since you are using STYLE overrides, that indicates you are not using LISTING destination. So what is your destination of interest.

2) your DEFINE statements for DIALYZER are confusing -- you have 2 DEFINE statements

define DIALYZER/ group  order '' ;

define DIALYZER/ center  style(column)={cellwidth=3.0in} noprint;

there is no point in changing the column width if you are going to "noprint" the column. What do you want to do with DIALYZER? It would be better to only have 1 DEFINE statement on the report.

3) I suspect you are getting a "GROUPS are not created .... " note in the log because you have a usage of ORDER for your "helper" variable ORDER and then you have a usage of GROUP for DIALYZER. If you want to see one report row for every value of DIALYZER, then it would be better to change that usage to ORDER for DIALYZER.

4) I agree with @Ballardw, that your statement "I need to  show output for each group in DIALYZER, in each box(not in each page) instead of all the groups in single box." is confusing. I do not know what it is that you want.

This is what I see in HTML when I run a modified version of your code. There is one report table with 5 DIALYZER categories: OVERALL, A, B, C and D. You want OVERALL to appear first, so you assign it a value of 1 for the ORDER helper variable.

PROC_REPORT_forum_question.png

I wonder why you repeat these rows.  It looks like you really only need the 3rd row of the data. More like this:

alternate_report.png

cynthia

Solution
‎06-20-2015 02:48 AM
Super User
Posts: 9,687

Re: SAS Report

How about this :

data dsn;
infile datalines dsd dlm=',';
input order DIALYZER$ Total_ $ Total $ Total1 $ Atleast_ $ Atleast $  Atleast1 $  ;
cards;
1,OVERALL,Total,Total,Total,Atleast,Atleast,Atleast
1,OVERALL,Total,Major,Minor,Atleast,Major,Minor
1,OVERALL,Total,0,20,Atleast,0 (0.00%),12 (60.00%)
2,A,Total,Total,Total,Atleast,Atleast,Atleast
2,A,Total,Major,Minor,Atleast,Major,Minor
2,A,Total,0,6,Atleast,0 (0.00%),6 (31.58%)
3,B,Total,Total,Total,Atleast,Atleast,Atleast
3,B,Total,Major,Minor,Atleast,Major,Minor
3,B,Total,0,4,Atleast,0 (0.00%),4 (20.00%)
4,C,Total,Total,Total,Atleast,Atleast,Atleast
4,C,Total,Major,Minor,Atleast,Major,Minor
4,C,Total,0,5,Atleast,0 (0.00%),5 (26.32%)
5,D,Total,Total,Total,Atleast,Atleast,Atleast
5,D,Total,Major,Minor,Atleast,Major,Minor
5,D,Total,0,5,Atleast,0 (0.00%),5 (26.32%)
;
run;
proc sort data=dsn;by order DIALYZER ;run;
ods html file='c:\temp\x.html'  options(pagebreak='no') style=sasweb ;
options nobyline;
ods escapechar='~';
ods text="~S={fontweight=bold fontsize=.5cm }%sysfunc(repeat(~_,48))Table 14.1.3*Descriptive Summary of Protocol Deviations" ;
title1 ' ';
title2 "#byval2";
PROC report data = dsn  nowd noheader ;
by order DIALYZER ;
column    Total Total1 Atleast Atleast1 ;
define Total/ center  ' ' style(column)={cellwidth=1.5in} ;
define Total1/ center '' style(column)={cellwidth=1.5in} ;
define Atleast/ center  ' ' style(column)={cellwidth=1.5in} ;
define Atleast1/ center ' ' style(column)={cellwidth=1.5in} ;
;quit;
ods html close;

x.png

Xia Keshan

Contributor
Posts: 48

Re: SAS Report

Hi

I have data as per below

Dialyzer

Category for

order

Total

Atleast

Protocol Deviation

overall

Major

1

0

0 (0.00%)

overall

Minor

1

10

10 (50.00%)

A

Major

2

0

0 (0.00%)

A

Minor

2

6

6 (31.58%)

B

Major

3

0

0 (0.00%)

B

Minor

3

4

4 (20.00%)

C

Major

4

0

0 (0.00%)

C

Minor

4

5

5 (26.32%)

D

Major

5

0

0 (0.00%)

D

Minor

5

5

5 (26.32%)

and I want output as below

Overall

Total

At least one

Major

Minor

Major

Minor

m

m

n (x.x%)

n (x.x%)

AA

Total

At least one

Major

Minor

Major

Minor

m

m

n (x.x%)

n (x.x%)

BB

Total

At least one

Major

Minor

Major

Minor

m

m

n (x.x%)

n (x.x%)

F8

Total

At least one

Major

Minor

Major

Minor

m

m

n (x.x%)

n (x.x%)

FX

Total

At least one

Major

Minor

Major

Minor

m

m

n (x.x%)

n (x.x%)

Super User
Posts: 9,687

Re: SAS Report

You can not include column header into a report , you need print it one by one .

If you really want print it in a report , the only thng I can think is changing HTML code, assuming your destination is HTML.

data dsn;
input DIALYZER $ category $ order total atleast : $40.;
cards;
Overall Major 1 0 0(0.00%)
Overall Minor 1 10 10(50.00
A Major 2 0 0(0.00%)
A Minor 2 6 6(31.58%)
;
run;
ods html file='c:\temp\x.html'  options(pagebreak='no') style=sasweb ;
options nobyline;
ods escapechar='~';
ods text="~S={fontweight=bold fontsize=.5cm }%sysfunc(repeat(~_,58))Table 14.1.3 ~n %sysfunc(repeat(~_,28))Descriptive Summary of Protocol Deviations" ;
title1 ' ';
title2 "#byval2";
options nobyline;
PROC report data = dsn  nowd  split = '*'  ;
by order  DIALYZER;
column DIALYZER Total,category  Atleast,category  ;
define DIALYZER/order noprint;
define category / across ' ';
define Total/ display ;
define Atleast/ display ; 
quit;
ods html close;

x.png

Xia Keshan

Super User
Posts: 9,687

Re: SAS Report

Code: Program

data dsn;
input DIALYZER $ category $ order total atleast : $40.;
cards;
Overall Major 1 0 0(0.00%)
Overall Minor 1 10 10(50.00
A Major 2 0 0(0.00%)
A Minor 2 6 6(31.58%)
;
run;
title " Table 14.1.3 ";
title2 "Descriptive Summary of Protocol Deviations";

PROC report data = dsn  nowd  split = '*'  noheader;
column order DIALYZER Total,category  Atleast,category;
define DIALYZER/ order noprint;
define order/order noprint ;
define category  /across;  
define Total/ display;
define Atleast/ display ;
compute before DIALYZER;
Line  ' ';
LINE  DIALYZER $;
line @4 'Total'  @30 'At Lease One';
endcomp;

;quit;

x.png

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 343 views
  • 0 likes
  • 4 in conversation