BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
StephenM
Fluorite | Level 6


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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
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

2 REPLIES 2
Ksharp
Super User
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;

StephenM
Fluorite | Level 6
Thank you. This helps clarify the report procedure a lot for me.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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