You can't mix row sets like that. You'll need to include an additional LookupRows()
:
%%[
var @rows, @row, @rowCount, @i
var @rows2 @row2, @rowCount2, @j
set @email = AttributeValue("_subscriberkey")
set @rows = LookupRows("DataExtension1","Email", @email)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowCount do
var @EmailAddress, @State, @Group
set @row = row(@rows,@i)
set @EmailAddress = field(@row,"Email")
set @State = field(@row,"State")
outputline(concat("<br>", @i , ". Email: ", @EmailAddress))
outputline(concat("<br>", @i , ". State: ", @State))
set @rows2 = LookupRows("DataExtension2","Email", @email)
set @rowCount2 = rowcount(@rows2)
if @rowsCount2 > 0 then
for @j = 1 to @rowCount2 do
set @row2 = row(@rows2,@j)
set @Group = field(@row2,"Group")
outputline(concat("<br>", @j , ". Group: ", @Group))
next @j
endif
next @i
else
outputline(concat("<br>no rows found"))
endif
]%%