I need to create a two-way table with the row variable as first surgery and column variable as second surgery per patient per day. I created a counter variable then created the variables CONDX1 and CONDX2 for first and second surgeries, but when I create the table, the values for CONDX2 are all in a separate row. How can I make it so CONDX2 indicates which surgeries were done the same day and for the same patient as those for CONDX1? Here is my code: PROC SORT DATA=PROJECT.COMPLETE; BY PT_ID EVENT_DATE; RUN; DATA VISITSCOUNTER; SET PROJECT.COMPLETE; BY PT_ID EVENT_DATE; IF FIRST.EVENT_DATE=1 THEN VISITS=0; VISITS+1; IF LAST.EVENT_DATE=1 THEN OUTPUT; RUN; DATA Question9; SET VISITSCOUNTER; BY PT_ID EVENT_DATE; IF VISITS=1 THEN CONDX1=CONDX; IF VISITS=2 THEN CONDX2=CONDX; RUN;
... View more