cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Learn some foundational elements of JMP Scripting Language (JSL) and how to extend point & click automation into repeatable, shareable routines. Register. June 26, 2 p.m. US Eastern Time.

Discussions

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

New column to label positive or negative

I have data in column :direction that is either positive, negative, or blank determined by a Lag formula 'in the column.

 

I created a new column :updown where I wanted to look at row of :direction. If it's positive or blank, I want updown for that row to be "Up", otherwise I want it to say "Down". This will simplify data filtering since we just want to split up multi-directional voltage data.

 

//Check Whether positive or negative
For(i=1, i<=N Rows(dt), i++,
if(:direction[i] < 0,
 :updown[i] << Set Value("Down");,
 :updown[i] << Set Value("Up");
);
);

I've done something similar previously but it doesn't seem to be working. I've tried a few different syntax options and nothing has worked.

 

Thanks in advance for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
SamGardner
Level VII

Re: New column to label positive or negative

I think you just need to  do this

 

//Check Whether positive or negative
For(i=1, i<=N Rows(dt), i++,
if(:direction[i] < 0,
 :updown[i] ="Down";,
 :updown[i] = "Up";
);
);

An alternative is to use a formula

 

column(dt, "updown") << Set Formula( If(:direction <0, "Down", "Up"))

View solution in original post

1 REPLY 1
SamGardner
Level VII

Re: New column to label positive or negative

I think you just need to  do this

 

//Check Whether positive or negative
For(i=1, i<=N Rows(dt), i++,
if(:direction[i] < 0,
 :updown[i] ="Down";,
 :updown[i] = "Up";
);
);

An alternative is to use a formula

 

column(dt, "updown") << Set Formula( If(:direction <0, "Down", "Up"))

Recommended Articles