As another alternative - without any subsetting/For Each:
names default to here(1);
dict = Open( "$DOWNLOADS/Dictionary1.jmp" );
dt = Open( "$DOWNLOADS/Dataset1.jmp" );
// stack the data for easy application of the dictionary
dt2=dt << Stack(
columns(
:ETHNICITY, :ETHCAT, :SEX, :NAME, :"A09:05"n, :"A01:01"n, :DPA05, :DPB04
),
Source Label Column( "col" ),
Stacked Data Column( "values" )
);
// add a column with the corrected column-identifiers
dt 2 << New Column( "column",
Character,
Formula(
Match( :col,
"A01:01", "A",
"A09:05", "A",
"DPA05", "DP",
"DPB04", "DP",
:col
)
)
);
// add the labels from the disctionary
dt2 <<
Update(
With( dict ),
Match Columns( :column = :Column, :values = :Values ),
Add Columns from Update Table( :Labels )
);
// convert back to a wide table
dt2 <<
Split(
Split By( :col ),
Split( :Labels ),
Group( :ID ),
Remaining Columns( Drop All )
);