The SAS Output Delivery System and reporting techniques

Listings with PROC Report

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Listings with PROC Report


Hi,

I'm having a bit of trouble making a listing out of my data and was hoping someone could point me in the right direction.

Below I've given a simplified version of my data. It consists of two patients (1001 and 1002) who came in on two different days (day01 and day02) to have two different tests (test01 and test02) which can have two different results (good or bad).


Patient   testday    test      result
1001      Day01     test01   good
1001      Day01    test02    bad
1001      Day02    test01   good
1001      Day02     test02  good
1002      Day01    test01  good
1002      Day01    test02  good
1002      Day02    test01  bad
1002      Day02    test02  bad

 

I would like to output the data in the following form:

 

Patient 1001:
            Day01 Day02
Test1    good   good
Test2     bad    good


Patient 1002:
           Day01 Day02
Test1  good    bad
Test2  good    bad

 

 

Now if the result variable was numeric I could make something like this quite easily using the tabulate procedure using a "table patient, test, testday*result" statement.

I can get something roughly equivalent using proc print and by variables but not exactly. I could also set about transposing the data into a new table and print that out.

However I think what I need to be using is the report procedure, but frankly I'm having little luck in working out what I need to do.

If someone could point me in the right direction that would be terrific.

Many thanks. 


Accepted Solutions
Solution
‎05-03-2016 04:14 AM
Super User
Posts: 9,681

Re: Listings with PROC Report

How about :
data have;
input Patient   (testday    test      result) ($);
cards;
1001      Day01     test01   good
1001      Day01    test02    bad
1001      Day02    test01   good
1001      Day02     test02  good
1002      Day01    test01  good
1002      Day01    test02  good
1002      Day02    test01  bad
1002      Day02    test02  bad
;
run;

proc report data=have nowd;
by Patient;
columns test testday,result;
define test/group ' ';
define testday/across ' ';
define result/group ' ';
run;

View solution in original post


All Replies
Solution
‎05-03-2016 04:14 AM
Super User
Posts: 9,681

Re: Listings with PROC Report

How about :
data have;
input Patient   (testday    test      result) ($);
cards;
1001      Day01     test01   good
1001      Day01    test02    bad
1001      Day02    test01   good
1001      Day02     test02  good
1002      Day01    test01  good
1002      Day01    test02  good
1002      Day02    test01  bad
1002      Day02    test02  bad
;
run;

proc report data=have nowd;
by Patient;
columns test testday,result;
define test/group ' ';
define testday/across ' ';
define result/group ' ';
run;

Occasional Contributor
Posts: 6

Re: Listings with PROC Report

Thank you. This helps clarify the report procedure a lot for me.
☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 310 views
  • 0 likes
  • 2 in conversation