turn on suggestions

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

Showing results for

- JMP User Community
- :
- Discussions
- :
- creating a new datasheet and copying values into i...

Topic Options

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

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

Nov 2, 2012 8:49 AM
(1855 views)

hi

i have a dataset with 50 numbers. I want to calculate the mean of the data set and place the mean value in a different new datasheet "Summary". Again I want to calculate sum of the 50 numbers and place it in the same new datasheet "Summary". Can some one help me how to place these mean and sum values in new datasheet "Summary"?

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions

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

Solution

Sorry, I inverted the fraction. It should read

fraction = k / N Rows**(** dt **)**;

This fraction (a number between 0 and 1) is calculated only because the random selection requires a fraction argument.

Here is a version that also puts each subsample in the output table. After the mean and SD columns you should see ten columns with the ten randomly picked data for each iteration.

dt = Data Table**(** "Data" **)**;

k = **10**; //Set sample size

n = **100**; //Set number of iterations

fraction = k / N Rows**(** dt **)**;

m = J**(** n, **2** + k **)**; //Initiate a matrix for holding means and SDs

//Loop: make random subset n times

For**(** i = **1**, i <= n, i++,

dt << select randomly**(** fraction **)**;

m**[**i, **1****]** = Mean**(** dt:Data**[**dt << get selected rows**]** **)**;

m**[**i, **2****]** = Std Dev**(** dt:Data**[**dt << get selected rows**]** **)**;

m**[**i, **3** :: **2**+ k**]** = transpose**(**dt:Data**[**dt << get selected rows**])**;

**)**;

//Move data into new table

dt2 = As Table**(** m **)**;

dt2 << set name**(** "Summary Data" **)**;

Column**(** dt2, **1** **)** << set name**(** "Mean" **)**;

Column**(** dt2, **2** **)** << set name**(** "StdDev" **)**;

14 REPLIES

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

Nov 5, 2012 8:39 AM
(1003 views)

Do you really mean to do this in JSL - i.e. to create a script that you can run to produce the summary? If you want to do this just one time interactively? I will answer both:

Interactively:

Create your data table - in this case i call it RawData,

Click Table >> Tabulate

Click Data and then Mean and drag it to the output area

Click Sum and drag it to the output area

Click on red triangle of the report >> Make into Data Table, or just use the report directly (Cut and Paste)

Using JSL

After creating the above using Make Into Data Table, name the table (Summary Report is used here)

Click on the red triangle >> Copy Script

Create a new script (File>>New>>Script)

Paste your newly copied script into the new script window

Close your previous summary report

Run the script you just created

The summary report should pop up

An example i made with random data:

Script:

New Table( "Summary Report",

Add Rows( 1 ),

New Script(

"Source",

(Data Table( "RawData" ) << Tabulate(

Add Table(

Column Table( Statistics( Mean, Sum ), Analysis Columns( :Data ) )

)

)) << Make Into Data Table

),

New Column( "Mean(Data)",

Numeric,

Continuous,

Format( "Best", 5 ),

Set Values( [171.936] )

),

New Column( "Sum(Data)",

Numeric,

Continuous,

Format( "Best", 5 ),

Set Values( [8596.8] )

)

)

Message me if you want my example files.

Barry

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

Nov 5, 2012 8:53 AM
(1003 views)

Actually, I wanted to do this:-i posted this question in the forum too..

I have a data set with 1000 variables, continous numbers. I want to take a random subset from the dataset and calculate the mean and standard deviation of the subset and place in a separate excel file "B". I want to repeat this process -process of taking the subset of size 10 from the original dataset with 1000 variables and calculate mean and standard deviation and place in the same excel file "B". The final excel sheet shll contain all the means and standard deviations .

Iam not very sure if the script that you have given me can help in creating a new sheet in the above question..

i attached my sample data sheet ..

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

Nov 5, 2012 9:17 AM
(1003 views)

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

Nov 5, 2012 10:25 AM
(1003 views)

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

Nov 5, 2012 11:53 AM
(1003 views)

Here is one way. The loop incrementally fills a matrix that is converted into a datatable at the end.

dt = Data Table**(** "Data" **)**;

k=**10**; //Set sample size

n = **100**; //Set number of iterations

fraction = **1** - k / N Rows**(** dt **)**;

m = J**(** n, **2** **)**; //Initiate a matrix for holding means and SDs

//Loop: make random subset n times

For**(** i = **1**, i <= n, i++,

dt << select randomly**(** fraction **)**;

m**[**i, **1****]** = Mean**(** dt:Data**[**dt << get selected rows**]** **)**;

m**[**i, **2****]** = Std Dev**(** dt:Data**[**dt << get selected rows**]** **)**;

**)**;

//Move data into new table

dt2 = As Table**(** m **)**;

dt2 << set name**(** "Summary Data" **)**;

Column**(** dt2, **1** **)** << set name**(** "Mean" **)**;

Column**(** dt2, **2** **)** << set name**(** "StdDev" **)**;

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

Nov 5, 2012 12:44 PM
(1003 views)

somehow I couldnot see the final table with means and standard deviations..where is it created?

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

Nov 5, 2012 12:46 PM
(1003 views)

can you please let me understand with this txt file. Sorry, but iam not much used to JSL,

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

Nov 5, 2012 1:19 PM
(1003 views)

If you don't care about some repeats in some samples, there is a SUBSET command under TABLES that produce random samples:

**Subset( Sample Size( 10 ) )**

that should produce the random 10 for each iteration.

As for the summary for each group, you can use STACK COMMAND to gather all data while preserving column (sampling group) names, then apply either tabulate or summary by sample group.

i'd like too give all that in a script but my scripting is very slow. may be later..

MS, excellent clean scripting, as always.

Barry

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

Nov 5, 2012 1:39 PM
(1003 views)

Thankyou everyone for helping me in JSL scripting...your skills are highly appreciated!