Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str6 id byte(index readmit30d tavr ppm)
"xxxyz"  1 . 1 0
"xxxyz"  0 1 0 1
"xxxyz"  0 . 0 0
"xxxyz"  0 . 0 0
"xx2ya"  1 . 0 0
"xx2ya"  0 1 0 0
"xx2ya"  0 . 0 0
"xx2ya"  0 . 0 0
"xxdw2"  1 . 0 0
"xxdw2"  0 1 1 0
"xxdw2"  0 . 0 0
"xx83js" 1 . 0 0
"xx83js" 0 1 0 1
"xx83js" 1 . 0 0
"xx83js" 0 1 1 0
"xx83js" 0 . 0 0
"xx83js" 0 . 0 0
"xsdsfa" 1 . 0 0
"atrsda" 1 . 0 0
"asf4aw" 1 . 0 0
"tawea"  1 . 0 0
"adfd33" 1 . 0 0
end

Hi,
please help me with this. The first col is patient ID, second is "index hospitalization" (if patients were admitted after 30 days, they were again considered to have index hospitalization), third is readmission within 30 days, fourth is a surgery procedure "TAVR", fifth is "PPM" (pacemaker implantation procedure).
My questions are:

1. How can I separate all TAVR patients in a separate dataset? I will like to keep all rows for that particular patient that had 1 in tavr column.
2. How can I find out if pacemaker "PPM" was placed in readmission (readmit30 = 1) or index admission? Looking for two separate columns to help me mark that and provide me with numbers.

Thanks.