The World Statistics Day celebration continues here in the Community. We all need reliable data for sound decision making. Do you have a data source that you trust most? Head over to Discussions to tell us about it.
Choose Language Hide Translation Bar
Highlighted
robust1972
Level IV

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

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
Highlighted
David_Burnham
Super User

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

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

View solution in original post

3 REPLIES 3
Highlighted
David_Burnham
Super User

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

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

View solution in original post

Highlighted
Jeff_Perkinson
Community Manager Community Manager

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

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
Highlighted
robust1972
Level IV

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

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

Article Labels

    There are no labels assigned to this post.