cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
awalts12
Level II

write selected rows to a new file

I have a script where I select rows from a table based on certain criteria:

dt << Select Where( :gender == "female" & :dx == "ild" );

How can I write these "selected rows" to a new file?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
DaveLee
Level IV

Re: write selected rows to a new file

awalts12,

Sounds like you have column A selected.  In that case JMP will subset the selected column and selected rows.

dt << Select Where( :gender == "female" & :dx == "ild" );

dt << Clear Column Selection();

sub=dt<<Subset(output table name(<Your Table Name>), Selected Rows(1));

View solution in original post

9 REPLIES 9
DaveLee
Level IV

Re: write selected rows to a new file

Awalts12,

You should be able to do the following:

dt << Select Where( :gender == "female" & :dx == "ild" );

sub=dt<<Subset(output table name(<Your Table Name>), Selected Rows(1));

Dave

awalts12
Level II

Re: write selected rows to a new file

This looks good ...

But it outputs only the first column (call it Column A) in each row. Is there a way to write the entire row (Columns A - Column R).

Thanks again

DaveLee
Level IV

Re: write selected rows to a new file

awalts12,

Sounds like you have column A selected.  In that case JMP will subset the selected column and selected rows.

dt << Select Where( :gender == "female" & :dx == "ild" );

dt << Clear Column Selection();

sub=dt<<Subset(output table name(<Your Table Name>), Selected Rows(1));

awalts12
Level II

Re: write selected rows to a new file

Thanks for the help  - this works nicely.

One other question as I am new to JMP's syntax. How can I include a wild card in the "select Where" command.

For example

dt << Select Where( :name == "A*")

doesn't seem to work - I'd like to be able to select all names starting with an A.

Thanks again.

txnelson
Super User

Re: write selected rows to a new file

dt << Select Where(substr(:name,1,1) == "A");

Jim
awalts12
Level II

Re: write selected rows to a new file

Back to the subset command, is there a way to suppress JMP from opening a new window with the subset of data?

I'm extracting 10 different subsets and then concatenating them together. So I need to generate each subset, but I don't need to see the subsets (except for debugging purposes) until they are concatenated. I have the concatenation coded fine, but every time i run my script I have to close the 10 "subset windows".

Thanks again

Avram

txnelson
Super User

Re: write selected rows to a new file

dt << select whee (substr(:name,1,1)=="A");

dt2 = dt << subset(invisible,selected columns(0), selected rows(1));

This will make the data table invisible to the user, however, it will still appear in the JMP Windows List.  You can substitute "Private" for "Invisible" and the new data table will be invisible to the user and the JMP Windows List.

Make sure you close the data tables when you are done with them,

close(dt2, nosave);

Jim

Jim
DaveLee
Level IV

Re: write selected rows to a new file

awalts12,

You can make the table invisible by doing the following and wrap it in a for loop to do all subsetting in one step.

dt << Select Where( :gender == "female" & :dx == "ild" );

dt << Clear Column Selection();

sub=dt<<Subset(output table name(<Your Table Name>), Selected Rows(1), Invisible);

ms
Super User (Alumni) ms
Super User (Alumni)

Re: write selected rows to a new file

The first column may have been selected. Try this to override any column selection:

sub = dt << Subset(output table name("my_sub"), Selected Rows(1), Selected Columns(0));