Hi,

I am relatively new to Stata so apologies if this is a basic question but I hope someone can help!

I have a large dataset (n=approx 30,000) with 95 variables containing ICD codes (s_41270_0_0-s_41270_0_95). I want to search within these variables for ICD codes corresponding to fractures - I have multiple codes for fractures (see code below). Is there a way of creating one new variable containing a list of the ICD codes for fractures from the 95 original variables.

I have been able to search one variable at a time for the ICD codes I'm interested in, although this creates a binary variable rather than keeping the information about which specific fractures (i.e. the new variable doesn't individually list the codes below)

Code:
icd10 generate fracture = s_41270_0_0, range ("T02"/"T020"/"T0200"/"T0201"/"T021"/"T0210"/"T0211"/"T022"/"T022"/"T0221"/"T023"/"T0230"/"T0231"/"T024"/"T0240"/"T0241"/"T025"/"T0250"/"T0251"/"T026"/"T0260"/"T0261"/"T027"/"T0270"/"T0271"/"T028"/"T0280"/"T0281"/"T029"/"T0290"/"T0291"/"T08"/"T08X0"/"T08X1"/"T10"/"T10X0"/"T10X1"/"T12"/"T12X0"/"T12X1"/"T142"/"T1420"/ "T1421")
So I am wondering if there is a way to create a loop to search within all the variables (i.e. s_41270_0_0-s_41270_0_95) to create one new variable with the list of fractures above?

Thank you!
Lisa