Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Exporting Select Columns to CSV Filtered by Formula Column

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 28, 2019 9:52 AM
(1860 views)

Hey everyone,

I'm new to JMP scripts and I'm hoping this may help others too. From the sample data screenshot below (stored as a .JMP file), I'd like to select Material and Month and round Stock to a whole number. I'd then like to filter only records where the rounded Stock calculation is greater than zero. Finally I'd like the results to be saved as a CSV file.

Here is my initial attempt at a JSL version. I'm pretty sure I'm not using the dt expressions correctly (likely among several other things as well) Any help would be tremendously appreciated.

```
dt = Open( "$SAMPLE_DATA\My JMP Table.jmp" );
columns(
:Material,
:Month,
New Column("Stock Integer", Numeric, "Continuous", Formula(Round( :Stock,0))
)
dt << Select Where Formula(Round( :Stock,0)) >=0
dt << save( "$Desktop\test.csv" );
```

Here is an SQL-like equivalent of what I'm trying to do

SELECT [My JMP Table].Material, [My JMP Table].Month, Round([My JMP Table].Stock,0) AS Stock_Integer INTO test.csv FROM [My JMP Table] WHERE Round([My JMP Table].[Stock],0)>0 ;

Thanks so much!

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I put this together quickly but it should work or be close.

```
dt1 = Open( "$SAMPLE_DATA\My JMP Table.jmp" );
For Each Row( :Stock = Round( :Stock, 0 ) );
dt1 << Select Where( :Stock >= 0 );
dt2 = dt1 << Subset( Selected Rows( 1 ), Columns( :Material, :Month, :Stock );
dt2 << Save( "$Desktop\test.csv" );
```

You were on the right path!

Learn it once, use it forever!

2 REPLIES 2

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I put this together quickly but it should work or be close.

```
dt1 = Open( "$SAMPLE_DATA\My JMP Table.jmp" );
For Each Row( :Stock = Round( :Stock, 0 ) );
dt1 << Select Where( :Stock >= 0 );
dt2 = dt1 << Subset( Selected Rows( 1 ), Columns( :Material, :Month, :Stock );
dt2 << Save( "$Desktop\test.csv" );
```

You were on the right path!

Learn it once, use it forever!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Exporting Select Columns to CSV Filtered by Formula Column

Wonderful, that worked perfectly. Thank you so much!

Article Labels

There are no labels assigned to this post.