I have looked at multiple posts but have not seen this exact situation addressed. The linked examples have more consistent variable names (not single/multiple underscores) and do not add the count column.
Dataset currently looks like this
idno sex age_1 date_visit_1 height_in_cm_1 age_2 date_visit_2 height_in_cm_2 age_3 date_visit_3 height_in_cm_3
20 M 10 10/1/2010 100 11 10/1/2011 110 12 10/2/2012 115
21 F 11 10/2/2010 90 12 11/3/2011 100 13 12/5/2012 105
22 M 12 11/3/2010 100 13 12/4/2011 105 14 12/5/2012 110
I want
idno sex age date_visit height_in_cm visit_no
20 M 10 10/1/2010 100 1
20 M 11 10/1/2011 110 2
20 M 12 10/2/2012 115 3
21 F 11 10/2/2010 90 1
21 F 12 11/3/2011 100 2
21 F 13 12/5/2012 105 3
22 M 12 11/3/2010 100 1
22 M 13 12/4/2011 105 2
22 M 14 12/5/2012 110 3
I have not been able to make it work. I either get two datasets stacked on each other, or the column names are wrong. The names_pattern and names_sep have not helped me since the format of the variable names is similar but not identical.