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.
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;
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;
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.
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.