Hi all,

My goal is to calculate time (days) from admission to the time a patient first received a surgical procedure, specifically, days from admission to the first "skin graft" performed for those who received this surgery. It seems straightforward, but allow me to explain this question which is actually a bit complicated.

In the NIS database, there are 25 procedure variables (PR1, PR2,..., PR25) for procedure coding (using ICD-10). And for each procedure variable, there is a corresponding variable indicating the days from admission to the time that procedure is performed (PRDAY1, PRDAY2,...,PRDAY25).

There are actually multiple ICD-10 codes for "skin graft". For example, "0HR0X73", "0HR1X73",...,"0HR7X73", and "0HR8X73" all mean "skin grafts", and they could be coded in any of the 25 procedure variables (PR1 - PR25).

We can imagine a scenario where a patient was coded "0HR0X73" in PR1 variable with "3" in the corresponding PRDAY1 variable and also coded "0HR1X73" in PR2 variable with "5" in the corresponding PRDAY2 variable. It means that this patient received a skin graft surgery on day 3 after admission and another skin graft surgery on day 5. Since my goal is to capture the time the first skin graft was performed, I would like to generate 2 variables, with one indicating that the patient received this procedure and the other one indicating it's day 3.

I am able to generate a variable indicating whether a patient received this procedure using the following codes, but I couldn't figure out a way to generate a variable indicating the time it's first performed.

gen Skingraft=0
forvalues j=1/25{
replace Skingraft=1 if inlist(PR`j', 0HR0X73", "0HR1X73",...,"0HR7X73", "0HR8X73" )
}

Thank in advance!