cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
SpannerHead
Level VI

Copy Column Groups From a Parent Table

I'm creating a summary from a parent table.  Columns in the parent table are grouped and I want to maintain the grouping in the summary table?  I have renamed columns in the summary to match the parent if that helps?


Slán



SpannerHead
3 REPLIES 3
jthi
Super User

Re: Copy Column Groups From a Parent Table

Have you taken a look at scripting index (<< Get Column Group Names, <<Get Column Group, << Group Columns)?

jthi_0-1751382075590.png

 

-Jarmo
SpannerHead
Level VI

Re: Copy Column Groups From a Parent Table

Jarmo

 

Did look there, couldn't make head nor tail.  Resorted to robbing part of an old script.  dt references the parent table and dtbest references the summary table.  Seems to work.

Grps = dt << Get Column Groups Names;

For( j = 1, j <= N Items( Grps ), j++,
colrefs={};
colrefs = dt << get column group(Grps[j]);

Group = dtBest << Group Columns(colrefs);
dtBest << rename column group( Group, Grps[j] );
	
);

 


Slán



SpannerHead
jthi
Super User

Re: Copy Column Groups From a Parent Table

For Each({groupname}, dt << Get Column Groups Names,
	cols = dt << Get Column Group(groupname);
	dt_new << Group Columns(groupname, cols);
);
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Cities.jmp");

dt << group columns("xy", {:X, :y}); // for demo purposes
dt << group columns("pollutants", :Ozone :: :Lead); // for demo purposes

dt_summary = dt << Summary(
	Group(:X, :Y, :OZONE, :CO, :SO2, :NO, :PM10, :Lead, :city),
	Freq("None"),
	Weight("None"),
	Link to original data table(0),
	output table name(
		"Summary of Cities grouped by X, Y, OZONE, CO, SO2, NO, PM10, Lead, city"
	)
);
dt_summary << Ungroup Columns(); // for demo purposes, they are grouped by default 

For Each({groupname}, dt << Get Column Groups Names,
	cols = dt << Get Column Group(groupname);
	dt_summary << Group Columns(groupname, cols);
);
-Jarmo

Recommended Articles