You don't need to use a macro for that, you can use simple C# code in your transformation like so
<%# ((DataItemIndex % 3 == 0) ? "<div class=\"row\"><div class=\"same-height\"> " : "" ) %>
This checks and says if its the first one of 3, place the <div> tags in front of the data item otherwise, just put an empty string.