Hi
I am new to JSL. I have to merge to columns vertically to a new column something like below. Any help is appreciated.
@adnan019 , There are multiple ways to do this. I will show you a few:
// Create Data Set 1 dt = New Table("Character Data"); dt << New Column("CharacterSet",Character,Nominal,<< Set Values({"A","B","C"})); // Create Data Set 2 dt1 = New Table("Numerical Data"); dt1 << New Column("NumericalSet",Character,Nominal,<< Set Values({"1","2","3"})); // Approach -1 dt2 = dt1 << Concatenate( dt); dt2 << New Column("ConcatenatedData",Character,Nominal,Formula(If(IsMissing(:CharacterSet),:NumericalSet,:CharacterSet))); // Approach - 2 ValsFromTable1 = dt:CharacterSet << Get Values; ValsFromTable2 = dt1:NumericalSet << Get Values; AllData = ValsFromTable1 || ValsFromTable2; dt3 = New Table (); dt3 << New Column("ConcatenatedSet",Character,Nominal,<<Set Values(AllData));
Note that I modeled the numerical data as character, this is to enable the concatenation
Or interactively:
First make sure the data type is for both columns character (or at least the same), otherwise concatenation won't work.
That's it.
And of course in the Source Script of the table you find the JSL approach:
Data Table( "MyData" ) << Stack( columns( :Col 1, :Col 2 ), Source Label Column( "Label" ), Stacked Data Column( "Data" ), Stack By Row( 0 ) )
I like the others from Uday, too.
Best
Martin
Thanks. The || sign worked for me.
Thanks Martin. Interactively that is also helpful.