cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
AdamChoen
Level IV

new column with all value set to zero

Hi
how can I create a new numeric column with all values are zero and not empty?

thanks!

Thanks, Adam
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: new column with all value set to zero

dt<<new column("All Zeros", set each value(0));

See the Scripting Index for details about this

     Help==>Scripting Index==>Data Table==>Column Scripting

Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: new column with all value set to zero

Create your new column, then go to the Column Info for the column, click on the down arrow for "Initialize Data" and select "Constant".  Then enter in your "0" and clock OK

zero.PNG

Jim
AdamChoen
Level IV

Re: new column with all value set to zero

thank Jim,
I forgot to ask for it, can I write it in JSL?

Thanks, Adam
txnelson
Super User

Re: new column with all value set to zero

dt<<new column("All Zeros", set each value(0));

See the Scripting Index for details about this

     Help==>Scripting Index==>Data Table==>Column Scripting

Jim
AdamChoen
Level IV

Re: new column with all value set to zero

As always, work great. Thank you Jim
Thanks, Adam
BSwid
Level IV

Re: new column with all value set to zero

For future searchers of a solution like this.

I wanted to do the same but with a character value like a file name for the source file upon import.  It seems like you have to declare Character in the New Column function to get it to work right.  Otherwise, it just populates with missing values.  Thanks.

This didn't work:

dt << New Column(colName, Set each value(fileName));

This did:

names default to here(1);
dt = current data table();

colName = "SourceFile";
fileName = dt << get name;

dt << New Column(colName, Character, Nominal, Set each value(fileName));

This thread had it:  https://community.jmp.com/t5/Discussions/Set-Column-Values/td-p/13584

Recommended Articles