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;
We need to see (a portion of) data set PROJECT.COMPLETE. Please provide the data was working SAS data step code, which you can type in yourself or you can follow these instructions. Do not attach files. Do not provide data as screen captures.
You say
but when I create the table, the values for CONDX2 are all in a separate row.
and I just don't see that when I run this code, I see CONDX2 never gets assigned a value.
So either the data you provided is not the same data that is causing the problem, or the code you provided is not the same code that is causing the problem (or both).
I am running the exact unchanged unedited code you posted. Maybe you posted the wrong code. Maybe the data you provided me doesn't match the data you are using.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Ready to level-up your skills? Choose your own adventure.