Subscribe Bookmark RSS Feed

How does one use a group of columns in a transpose data statement

mikeret57

Community Trekker

Joined:

Jun 27, 2014

Greetings,

     Long time SAS programmer but new to JSL.   I have a data table and have been able to create a group containing say 20 columns.  Running this report next week, It may have 25 columns in the same group and I am looking to find a way to transpose the data table using this variable list of columns.  Using JSL, how does one modify the script below to operate off the group name instead of the individual list of columns?  The column group name is "HB_001 etc."

Data Table( "tran_HB" ) << Transpose(

  columns(

  :HB_001,

  :HB_002,

  :HB_003,

  :HB_004,

  :HB_005,

  :HB_006,

  :HB_007,

  :HB_008,

  :HB_010,

  :HB_012

  ),

  By( :Family, :group ),

  Label( :Label ),

  Output Table( "sum_HB_w_0" )

);

Thanks,  Mike

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

Use << get column group("group name") to get a list of the columns of the group.

An example:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Cities.jmp" );

dt << group columns( "xy", {:X, :y} );

dt << Transpose(

  columns( dt << get column group( "xy" ) ),

  Label( :city ),

  Label column name( "city" ),

  Output Table( "Transpose of Cities.jmp" )

);

2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Solution

Use << get column group("group name") to get a list of the columns of the group.

An example:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Cities.jmp" );

dt << group columns( "xy", {:X, :y} );

dt << Transpose(

  columns( dt << get column group( "xy" ) ),

  Label( :city ),

  Label column name( "city" ),

  Output Table( "Transpose of Cities.jmp" )

);

mikeret57

Community Trekker

Joined:

Jun 27, 2014

This works great!  Thank you for your help