Subscribe Bookmark RSS Feed

subset a table with category in a column and name the sub tables with the cat. name

robust1972

Community Trekker

Joined:

Jan 15, 2014

subset a table with category in a column and name the sub tables with the cat. name;

I wrote a short script as below but it name both table as "F" and "F2", rather than "F" and "M". Anything I did wrongly?

Names default to here(1);

dt=open("$SAMPLE_DATA/big class.jmp");

dtsumm = dt << Summary(

       Group( :sex )

);

for(x=1,x<=nrow(dtsumm),x++,

  dt<<select where(dt:sex==dtsumm:sex)<< subset(Output Table Name(:sex));

);

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

I think where you are using :sex for the output table name you just need to replace it with dtsumm:sex.  Its picking up the values from the source table not the summary table.

-Dave
3 REPLIES
Solution

I think where you are using :sex for the output table name you just need to replace it with dtsumm:sex.  Its picking up the values from the source table not the summary table.

-Dave
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Dave@Pega-Analytics​ is right. It's always good practice to scope your references.

Alternatively, you could let JMP do the subsetting by categories using the By() option in Subset():

Data Table( "Big Class.jmp" ) << Subset(

By( :sex ),

All rows,

Selected columns only( 0 ),

columns( :name, :age, :height, :weight )

)

No need for the Summary() or the For() loop.

-Jeff
robust1972

Community Trekker

Joined:

Jan 15, 2014

need the loop in following processes. just use the example table to show the problem I had.