cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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