The SAS Output Delivery System and reporting techniques

proc report issue

Reply
Contributor
Posts: 20

proc report issue

I have data in following format
Patno cycle visit date_visit
1 scr 0 010108
1 c1 1 010208
1 c1 2 010308
1 c2 3 010408
1 c2 4 010508
1 c3 5 010608
1 c3 6 010708
under each cycle, except screening, there are two visits...

I just want a report in the following format..
Patient Scr c1 c2 c3
number 0 1 2 3 4 5 6
1 010108 010208 010308 010408 010508 010608 010708
.................
...........
it would be greatly helpful if some body can help me...Thank you
SAS Super FREQ
Posts: 8,743

Re: proc report issue

Hi:
You'll probably need to transform your data from long, skinny data into one observation per patient with the date variables appearing as numbered variables. This is a good job for either PROC TRANSPOSE (or a DATA step program) -- but PROC TRANSPOSE probably lends itself to this kind of data.

If you ran PROC TRANSPOSE, as shown in the program below, then your PROC REPORT (or PROC PRINT) program would be fairly simple, since COL1 would always be the SCR date and COL2-COL7 would be the 6 visit dates. (I had to make some data, so your version of the program would start with the PROC TRANSPOSE step and not with the first DATA step.)

cynthia
[pre]
** first, make some test data;
data visit;
infile datalines;
input patno cycle $ visit date_visit : mmddyy6.;
return;
datalines;
1 scr 0 010108
1 c1 1 010208
1 c1 2 010308
1 c2 3 010408
1 c2 4 010508
1 c3 5 010608
1 c3 6 010708
2 scr 0 010508
2 c1 1 010608
2 c1 2 010708
2 c2 3 010808
2 c2 4 010908
2 c3 5 011008
2 c3 6 011108
3 scr 0 030108
3 c1 1 030208
3 c2 2 030308
3 c2 3 030408
3 c2 4 030508
3 c3 5 030608
3 c3 6 030708
4 scr 0 050508
4 c1 1 050608
4 c1 2 050708
4 c2 3 050808
4 c2 4 050908
4 c3 5 051008
4 c3 6 051108
;
run;

** now, transpose the visit data;
** since the visits follow a regular patter, just transpose date_visit;
proc transpose data=visit out=visit_out;
by patno;
var date_visit;
run;

ods listing close;

ods html file='visit.html' style=sasweb;
proc print data=visit_out label split='/';
title1 'proc print with transposed dates';
var patno col1-col7;
format col1-col7 mmddyy10.;
label col1 = 'scr/0'
col2 = 'c1/1'
col3 = 'c1/2'
col4 = 'c2/3'
col5 = 'c2/4'
col6 = 'c3/5'
col7 = 'c3/6';
run;

proc report data=visit_out nowd;
title 'proc report with transposed dates';
column patno ('scr' col1) ('c1' col2 col3)
('c2' col4 col5) ('c3' col6 col7);
define patno / order;
define col1 / display '0' f=mmddyy6.;
define col2 /display '1' f=mmddyy6.;
define col3 /display'2' f=mmddyy6.;
define col4 /display '3' f=mmddyy6.;
define col5 /display'4' f=mmddyy6.;
define col6 /display'5' f=mmddyy6.;
define col7 /display '6' f=mmddyy6.;
run;
ods html close;

[/pre]
Ask a Question
Discussion stats
  • 1 reply
  • 110 views
  • 0 likes
  • 2 in conversation