Subscribe Bookmark RSS Feed

Naming of Subset with Original File name with _New appended

d_barnett

Community Trekker

Joined:

Nov 30, 2011

I have an 'original data table that I take a subset from and wish to rename the new file with the original filename but with _new appended to the filename.

e.g.

Original filename

001751-00001-1-1-VAM

after subsetting it I want to rename it

0001751-00001-1-1-VAM_new

I  thought that the rename file script would do it but I can't make it pick out the name of the original file, append then save the file.

any help would be most appreciated.

Regards

David

3 REPLIES
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Would something like this work?

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

dt << select where( :sex == "M" );

dt << Subset( Output Table( Word( 1, dt << get name, "." ) || "_new" ), Selected Rows( 1 ) );

It uses a reference to the original data table, dt, and the get name message to get the name and appends "_new" as you requested.

-Jeff

-Jeff
dlee0416

Community Trekker

Joined:

Jun 11, 2014

jeff.perkinson​'s reply was spot on except there should be Selected Rows(1)

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

dt << select where( :sex == "M" );

dt << Subset( Output Table( Word( 1, dt << get name, "." ) || "_new" ), Selected Rows( 1 ) );

Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Yikes! You're right!

I've edited my reply to correct this. Sorry!

-Jeff