topic Re: Value selection and copy into new columns in Discussions
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78875#M36593
<P>Hey, here is the full version without the Show functions as those were not of any use in my case.</P><P>Thanks for your help!</P><P> </P><PRE><CODE class=" language-jsl">dt = Current Data Table(); // Assuming the data table is open
/* Step 1 - add 3 columns */
dt << New Column("sign_0,09",Numeric,Continuous)
<< New Column("sign_0,05",Numeric,Continuous)
<< New Column("sign_0,01",Numeric,Continuous);
// Getting the values of column of interest
ColVals = dt:Name("p-value (two-sided test) 2") << Get Values;
// Set up a dummy matrix
Dummy = J(NRows(dt),1,.);
// All Rows
AllRows = Index(1,NRows(dt),1);
/* Step 2 - Select from the column based on conditions */
/* This could also be replaced by loop */
SR1 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.09);
//do not change "." to "," as the programme uses "." for background calculation
Dummy[SR1,0] = ColVals[SR1];
dt:Name("sign_0,09") << Set Values(Dummy);
// Re-initialize dummy matrix
Dummy = J(NRows(dt),1,.);
SR2 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.05);
Dummy[SR2,0] = ColVals[SR2];
dt:Name("sign_0,05") << Set Values(Dummy);
// Re-initialize dummy matrix
Dummy = J(NRows(dt),1,.);
SR3 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.01);
Dummy[SR3,0] = ColVals[SR3];
dt:Name("sign_0,01") << Set Values(Dummy);
/* End of Step 2 */
/* Step 3 */
dt << Select Where (Name("p-value (two-sided test)2") <= 0.09);
dt << Subset( Output Table( "new_0,09" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.05);
dt << Subset( Output Table( "new_0,05" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.01);
dt << Subset( Output Table( "new_0,01" ), Selected Rows( 1 ), selected columns( 0 ) );
/* End of Step 3 */</CODE></PRE><P><BR /><BR /></P>Sat, 13 Oct 2018 09:33:57 GMTPacco2018-10-13T09:33:57ZValue selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78825#M36561
<P>Hey,</P>
<P> </P>
<P>I´m trying to automatize a (seemingly fairly easy) <STRONG>value selection, column creation and copy/paste</STRONG> process, however, I cannot find the right script compilation for it.</P>
<P> </P>
<P>1) I need to create <STRONG>3 new columns</STRONG> adding a different selection of values from one <STRONG>same source column</STRONG> to each of those 3 new columns and create a <STRONG>subset</STRONG> of each selection <STRONG>when all columns are filled in</STRONG>.</P>
<P>2) The name of the subsets should correspond to the header of the original source file plus a new appendix.</P>
<P> </P>
<P><EM>Be aware:</EM></P>
<P>The location of columns and the amount of rows varies in the data files I have, however, the names are all the same.</P>
<P> </P>
<P>I tried these two scripts which of course are not correct but I do not know what to change exactly to make it work. Any suggestions?</P>
<P> </P>
<P><STRONG>Version 1:</STRONG></P>
<P> </P>
<PRE><CODE class=" language-jsl">Names Default To Here( 1 );
dt = Current Data Table();
//Select values to copy into new column
vals 1 = Select Where (:p-value (two-sided test)2 <= 0,09); //it seems that the "2" in the column name is confusing, but unfortunately, it would take a long time to go through all tables and change the column name
// Put these in a new column 1
dt = NewColumn("sign_0,09", Numeric, Continuous, Values(vals1));
Wait( 5 );
//Column 2
vals 2 = Select Where (:p-value (two-sided test)2 <= 0,05);
dt<<get selected rows
dt = NewColumn("sign_0,05", Numeric, Continuous, Values(vals2));
Wait( 5 );
//Column 3
vals 3 = Select Where (:p-value (two-sided test)2 <= 0,01);
dt<<get selected rows
dt = NewColumn("sign_0,01", Numeric, Continuous, Values(vals3));
//Create subsets
dt << Select where :sign_0,09 != "";
dt<< Get selected rows
//the new name should be automatically given, too, is that possible?
dt << Subset( Output Table( "name as in original file plus _0,09 at the end" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select where :sign_0,05 != "";
dt<< Get selected rows
dt << Subset( Output Table( "name as in original file plus _0,05 at the end" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select where :sign_0,01 != "";
dt<< Get selected rows
dt << Subset( Output Table( "name as in original file plus _0,01 at the end" ), Selected Rows( 1 ), selected columns( 0 ) );</CODE></PRE>
<P> </P>
<P> </P>
<P><STRONG>Version 2:</STRONG></P>
<PRE><CODE class=" language-jsl">Names Default To Here( 1 );
dt = Current Data Table();
dt << :p-value (two-sided test)2 = [1,?]; //the end row varies and must be found automatically
results << New Column("sign_0,09", Numerical, Continuous);
For( i = 1, i <= NItems( "p-value (two-sided test)2"), i++,
results << Select Where (:p-value (two-sided test)2 <= 0,09) );
selRows = results << getSelectedRows;
AsColumn( results, "sign_0,09" )[selRows] = "p-value (two-sided test)2"[i];
//same process for 2 other new columns
dt<<Subset
dt << Select where :sign_0,09 != "";
dt<< Get selected rows
//the new name should be automatically given, too, is that possible?
dt << Subset( Output Table( "name as in original file plus _0,09 at the end" ), Selected Rows( 1 ), selected columns( 0 ) );
//same process for other 2 columns</CODE></PRE>
<P> </P>
<P><FONT color="#000000">I would be very happy to find a solution as in the threads so far there is often a copy/paste into new data tables, however, "never" into a new column, and mostly it´s related to a string selection it seems. Not sure if the selection works the same for numerical data.</FONT></P>
<P> </P>
<P><FONT color="#000000">Thanks for any help!</FONT></P>Fri, 12 Oct 2018 14:27:03 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78825#M36561Pacco2018-10-12T14:27:03ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78838#M36569
<P><LI-USER uid="10528"></LI-USER> ,<BR /> Lets see how I can try and help. First things first, a request from my end is when you are pasting code, please paste it using the "JSL" code block, so it is easy for the community member s to read through your code. Now, once we have taken care of that, looking through your code: </P><P> </P><P>1. <SPAN>vals 1 = Select Where (:p-value (two-sided test)2 <= 0,09); /</SPAN><FONT color="#339966">/it seems that the "2" in the column name is confusing, but unfortunately, it would take a long time to go through all tables and change the column name</FONT><BR />- When you have a complicated name like this for a column and don't want to change it, it would be advisable to use the name() . so the above line should be re-written as : </P><P> </P><PRE><CODE class=" language-jsl">vals1 = Select Where (Name("p-value (two-sided test)2 ")<= 0,09); // I don't know if you are using European convention for the comma instead of decimal</CODE></PRE><P>2. Now, a select where statement is a message that is issued to a data table, so the above line of code should further be refined as : </P><P> </P><PRE><CODE class=" language-jsl">vals1 = dt << Select Where (Name("p-value (two-sided test)2") <= 0,09); </CODE></PRE><P>If you would be kind enough to try these suggestions and maybe provide a sample dataset, I can try to fix the other issues as well. </P><P> </P><P> </P>Fri, 12 Oct 2018 14:30:58 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78838#M36569uday_guntupalli2018-10-12T14:30:58ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78839#M36570
<P>I've read your description of what you're trying to do but I'm having difficulty understanding it without a concrete example. Additionally, since your JSL isn't doing what you'd like it to do it's difficult to use that to guess how to help you.</P>
<P> </P>
<P>Could you post some more details about exactly what you're trying to do, preferably with screen shots of the data tables in question and what you'd like to end up with? I think that would help us in the Community to help you more directly.</P>
<P> </P>
<P>Thanks.</P>Fri, 12 Oct 2018 14:32:10 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78839#M36570Jeff_Perkinson2018-10-12T14:32:10ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78840#M36571
<P>Hey,</P><P> </P><P>Thank you very much for the input. This is already very helpful to know.</P><P>I´m sorry for the wrong copying of the script. I´ll keep it in mind for next time.</P><P> </P><P>To make it more clear what I am trying to do I attach a stepwise overview of what the result should look like. I hope the guide gives more clarity.</P><P> </P><P>I also attach the example in jmp format.</P><P> </P><P>Thanks for the help!</P>Fri, 12 Oct 2018 15:59:44 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78840#M36571Pacco2018-10-12T15:59:44ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78841#M36572
Fri, 12 Oct 2018 16:01:39 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78841#M36572Pacco2018-10-12T16:01:39ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78842#M36573
<P>Hi Jeff,</P><P> </P><P>Thanks for having a look, too.</P><P>I attached the files in my reply above! I hope they clarify my question.</P><P> </P><P> </P><P> </P>Fri, 12 Oct 2018 16:04:55 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78842#M36573Pacco2018-10-12T16:04:55ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78847#M36575
<P><LI-USER uid="10528"></LI-USER>,<BR /> Ok, this should get you 90% of the way there. </P><P> </P><P> </P><PRE><CODE class=" language-jsl">dt = Current Data Table(); // Assuming the data table is open
/* Step 1 - add 3 columns */
dt << New Column("sign_0,09",Numeric,Continuous)
<< New Column("sign_0,05",Numeric,Continuous)
<< New Column("sign_0,01",Numeric,Continuous);
// Getting the values of column of interest
ColVals = dt:Name("p-value (two-sided test) 2") << Get Values;
// Set up a dummy matrix
Dummy = J(NRows(dt),1,.);
// All Rows
AllRows = Index(1,NRows(dt),1);
/* Step 2 - Select from the column based on conditions */
/* This could also be replaced by loop */
SR1 = dt << Select Where(:Name("p-value (two-sided test) 2") <= 0.09) << Get Selected Rows; // You can edit this to conform to european convention of 0,09
dt << Clear Select;
Dummy[SR1,0] = ColVals[SR1];
dt:Name("sign_0,09") << Set Values(Dummy);
// Re-initialize dummy matrix
Dummy = J(NRows(dt),1,.);
SR2 = dt << Select Where(:Name("p-value (two-sided test) 2") <= 0.05) << Get Selected Rows; // You can edit this to conform to european convention of 0,05
dt << Clear Select;
Dummy[SR2,0] = ColVals[SR2];
dt:Name("sign_0,05") << Set Values(Dummy);
// Re-initialize dummy matrix
Dummy = J(NRows(dt),1,.);
SR3 = dt << Select Where(:Name("p-value (two-sided test) 2") <= 0.01) << Get Selected Rows; // You can edit this to conform to european convention of 0,01
dt << Clear Select;
Dummy[SR3,0] = ColVals[SR3];
dt:Name("sign_0,01") << Set Values(Dummy);
/* End of Step 2 */
/* Step 3 */
// We already have the rows that meet the conditions
Show(SR1);
Show(SR2);
Show(SR3);
/* End of Step 3 */ <BR /></CODE></PRE><P> <LI-USER uid="6878"></LI-USER>, <BR /> Is there an easy way to find common elements between matrices ? Maybe Design() might help, but can you provide an example </P><P> </P><PRE><CODE class=" language-jsl">A = [1,2,3,4,5,6];
B = [1,2,3];
C = [3,5];
// The common element would be 3 </CODE></PRE><P> I know I could use associative arrays and the intersect functionality, but shouldn't matrices have an easy way to determine common/uncommon elements. </P>Fri, 12 Oct 2018 17:45:19 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78847#M36575uday_guntupalli2018-10-12T17:45:19ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78848#M36576
<P>That looks great. I will test it as soon as possible.</P><P> </P><P>If you refer to common elements within the 3 new columns then this is only the case regarding the selected values that will be added to each of the columns!</P><P> </P><P>E.g. the selection of values <= 0,01 will also appear in columns with 0,05 and 0,09 and the ones <= 0,05 will appear also in 0,09.</P><P>Simplified:</P><P>A = [<FONT color="#99CC00">0,01</FONT>,<FONT color="#0000FF">0,05</FONT>,0,09]</P><P>B = [<FONT color="#99CC00">0,01</FONT>,<FONT color="#0000FF">0,05</FONT>]</P><P>C = [<FONT color="#99CC00">0,01</FONT>]</P><P>However, there will NOT be any other pattern or kind of "every second row is equal in all three rows" structure.</P><P>Thus, yes, maybe there is a way to work with matrices and make the whole process smoother.</P><P> </P><PRE class=" language-jsl"><CODE class=" language-jsl">A <SPAN class="token operator">=</SPAN> <SPAN class="token punctuation">[</SPAN><SPAN class="token number">1</SPAN><SPAN class="token punctuation">,</SPAN><SPAN class="token number">2</SPAN><SPAN class="token punctuation">,</SPAN><SPAN class="token number">3</SPAN><SPAN class="token punctuation">,</SPAN><SPAN class="token number">4</SPAN><SPAN class="token punctuation">,</SPAN><SPAN class="token number">5</SPAN><SPAN class="token punctuation">,</SPAN><SPAN class="token number">6</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">;</SPAN>
B <SPAN class="token operator">=</SPAN> <SPAN class="token punctuation">[</SPAN><SPAN class="token number">1</SPAN><SPAN class="token punctuation">,</SPAN><SPAN class="token number">2</SPAN><SPAN class="token punctuation">,</SPAN><SPAN class="token number">3</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">;</SPAN>
C <SPAN class="token operator">=</SPAN> <SPAN class="token punctuation">[</SPAN><SPAN class="token number">3</SPAN><SPAN class="token punctuation">,</SPAN><SPAN class="token number">5</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">;</SPAN></CODE></PRE><P> </P>Fri, 12 Oct 2018 17:57:46 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78848#M36576Pacco2018-10-12T17:57:46ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78850#M36578
<P>I see this approach but there is a simpler way that does involve changing the selected row state. Instead of this:</P>
<P> </P>
<PRE><CODE class=" language-jsl">SR1 = dt << Select Where(:Name("p-value (two-sided test) 2") <= 0.09) << Get Selected Rows; <BR />// You can edit this to conform to european convention of 0,09
dt << Clear Select; </CODE></PRE>
<P>You can just use this:</P>
<P> </P>
<PRE><CODE class=" language-jsl">SR1 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.09)
// You can edit this to conform to european convention of 0,09</CODE></PRE>
<P> </P>
<P>This way you don't disturb the current row seletion.</P>Fri, 12 Oct 2018 18:46:24 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78850#M36578markbailey2018-10-12T18:46:24ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78859#M36581
<P>Thanks for posting some more details, that helps some. Instead of trying to create the new columns and filling them with values all through JSL, I would just create three new formula based columns with the formula:</P>
<P> </P>
<PRE><CODE class=" language-jsl">If( :Name( "p-value (two-sided test) 2" ) <= 0.09,
:Name( "p-value (two-sided test) 2" )
)</CODE></PRE>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JMPScreenSnapz288.png" style="width: 999px;"><img src="https://kvoqx44227.i.lithium.com/t5/image/serverpage/image-id/12782iBC420F4A62F26336/image-size/large?v=1.0&px=999" title="JMPScreenSnapz288.png" alt="JMPScreenSnapz288.png" /></span></P>
<P> </P>
<P> </P>
<PRE><CODE class=" language-jsl">dt = Open( "seas_ratio_1_monthly.jmp" );
dt << New Column( "sign_0.09",
Numeric,
"Nominal",
Format( "Best", 9 ),
Formula(
If( :Name( "p-value (two-sided test) 2" ) <= 0.09,
:Name( "p-value (two-sided test) 2" )
)
)
);
dt << New Column( "sign_0.05",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( :Name( "p-value (two-sided test) 2" ) <= 0.05,
:Name( "p-value (two-sided test) 2" )
)
)
);
dt << New Column( "sign_0.01",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( :Name( "p-value (two-sided test) 2" ) <= 0.01,
:Name( "p-value (two-sided test) 2" )
)
)
);</CODE></PRE>
<P>But, I must admit that I'm still not sure what the value of the data tables with only the rows that are significant at a particlar level. How are you going to use those tables? Do they need all three significance indicator columns (i.e., sign_0,09; sign_0,05; and sign_0,01)? If not you can avoid creating those columns all together and just subset the rows that less than each level. Can you tell us more about your ultimate goal and why you want data tables like you describe? We may be able to provide even easier methods.</P>Fri, 12 Oct 2018 20:30:43 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78859#M36581Jeff_Perkinson2018-10-12T20:30:43ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78870#M36588
<P><LI-USER uid="6696"></LI-USER></P><P> </P><P>I ran the script with my data (your version and with the exchange of the suggestion of <LI-USER uid="5358"></LI-USER>) and it works to create the columns and to get the selected data into the new column.</P><P>However, the last part (see below) to show the selected rows does not work. I adjusted it with a Select Where and Create Subset.</P><PRE><CODE class=" language-jsl">/* Step 3 */
// We already have the rows that meet the conditions
Show(SR1);
Show(SR2);
Show(SR3);
/* End of Step 3 */ </CODE></PRE><PRE><CODE class=" language-jsl">/* Step 3 */
dt << Select Where (Name("p-value (two-sided test)2") <= 0.09);
dt << Subset( Output Table( "new_0,09" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.05);
dt << Subset( Output Table( "new_0,05" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.01);
dt << Subset( Output Table( "new_0,01" ), Selected Rows( 1 ), selected columns( 0 ) );
/* End of Step 3 */ </CODE> </PRE><P> </P>Sat, 13 Oct 2018 09:22:07 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78870#M36588Pacco2018-10-13T09:22:07ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78872#M36590
Sat, 13 Oct 2018 09:22:39 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78872#M36590Pacco2018-10-13T09:22:39ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78873#M36591
<P><LI-USER uid="6878" login="Jeff_Perkinson"></LI-USER></P><P>Thank you Jeff,</P><P>I had read your post too late. I just added the create subsets part to the selection you proposed and apart from the automatized name creation it works perfectly. Thank you for the suggestion.</P><P> </P><PRE><CODE class=" language-jsl">dt = Current Data Table();
dt << New Column( "sign_0,09",
Numeric,
"Nominal",
Format( "Best", 9 ),
Formula(
If( :Name( "p-value (two-sided test) 2" ) <= 0.09,
:Name( "p-value (two-sided test) 2" )
)
)
);
dt << New Column( "sign_0,05",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( :Name( "p-value (two-sided test) 2" ) <= 0.05,
:Name( "p-value (two-sided test) 2" )
)
)
);
dt << New Column( "sign_0,01",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( :Name( "p-value (two-sided test) 2" ) <= 0.01,
:Name( "p-value (two-sided test) 2" )
)
)
);
/* Step 3 */
// We already have the rows that meet the conditions
dt << Select Where (Name("p-value (two-sided test)2") <= 0.09);
dt << Subset( Output Table( "new_0,09" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.05);
dt << Subset( Output Table( "new_0,05" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.01);
dt << Subset( Output Table( "new_0,01" ), Selected Rows( 1 ), selected columns( 0 ) );
/* End of Step 3 */ </CODE></PRE>Sat, 13 Oct 2018 09:25:15 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78873#M36591Pacco2018-10-13T09:25:15ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78874#M36592
<P>Hey, here is the full version without the Show functions as those were not of any use in my case.</P><P>Thanky for your help!</P><P> </P><PRE><CODE class=" language-jsl">dt = Current Data Table(); // Assuming the data table is open
/* Step 1 - add 3 columns */
dt << New Column("sign_0,09",Numeric,Continuous)
<< New Column("sign_0,05",Numeric,Continuous)
<< New Column("sign_0,01",Numeric,Continuous);
// Getting the values of column of interest
ColVals = dt:Name("p-value (two-sided test) 2") << Get Values;
// Set up a dummy matrix
Dummy = J(NRows(dt),1,.);
// All Rows
AllRows = Index(1,NRows(dt),1);
/* Step 2 - Select from the column based on conditions */
/* This could also be replaced by loop */
SR1 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.09);
//do not change "." to "," as the programme uses "." for background calculation
Dummy[SR1,0] = ColVals[SR1];
dt:Name("sign_0,09") << Set Values(Dummy);
// Re-initialize dummy matrix
Dummy = J(NRows(dt),1,.);
SR2 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.05);
Dummy[SR2,0] = ColVals[SR2];
dt:Name("sign_0,05") << Set Values(Dummy);
// Re-initialize dummy matrix
Dummy = J(NRows(dt),1,.);
SR3 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.01);
Dummy[SR3,0] = ColVals[SR3];
dt:Name("sign_0,01") << Set Values(Dummy);
/* End of Step 2 */
/* Step 3 */
dt << Select Where (Name("p-value (two-sided test)2") <= 0.09);
dt << Subset( Output Table( "new_0,09" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.05);
dt << Subset( Output Table( "new_0,05" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.01);
dt << Subset( Output Table( "new_0,01" ), Selected Rows( 1 ), selected columns( 0 ) );
/* End of Step 3 */</CODE></PRE><P><BR /><BR /></P>Sat, 13 Oct 2018 09:33:53 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78874#M36592Pacco2018-10-13T09:33:53ZRe: Value selection and copy into new columns
https://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78875#M36593
<P>Hey, here is the full version without the Show functions as those were not of any use in my case.</P><P>Thanks for your help!</P><P> </P><PRE><CODE class=" language-jsl">dt = Current Data Table(); // Assuming the data table is open
/* Step 1 - add 3 columns */
dt << New Column("sign_0,09",Numeric,Continuous)
<< New Column("sign_0,05",Numeric,Continuous)
<< New Column("sign_0,01",Numeric,Continuous);
// Getting the values of column of interest
ColVals = dt:Name("p-value (two-sided test) 2") << Get Values;
// Set up a dummy matrix
Dummy = J(NRows(dt),1,.);
// All Rows
AllRows = Index(1,NRows(dt),1);
/* Step 2 - Select from the column based on conditions */
/* This could also be replaced by loop */
SR1 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.09);
//do not change "." to "," as the programme uses "." for background calculation
Dummy[SR1,0] = ColVals[SR1];
dt:Name("sign_0,09") << Set Values(Dummy);
// Re-initialize dummy matrix
Dummy = J(NRows(dt),1,.);
SR2 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.05);
Dummy[SR2,0] = ColVals[SR2];
dt:Name("sign_0,05") << Set Values(Dummy);
// Re-initialize dummy matrix
Dummy = J(NRows(dt),1,.);
SR3 = dt << Get Rows Where(:Name("p-value (two-sided test) 2") <= 0.01);
Dummy[SR3,0] = ColVals[SR3];
dt:Name("sign_0,01") << Set Values(Dummy);
/* End of Step 2 */
/* Step 3 */
dt << Select Where (Name("p-value (two-sided test)2") <= 0.09);
dt << Subset( Output Table( "new_0,09" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.05);
dt << Subset( Output Table( "new_0,05" ), Selected Rows( 1 ), selected columns( 0 ) );
dt << Select Where (Name("p-value (two-sided test)2") <= 0.01);
dt << Subset( Output Table( "new_0,01" ), Selected Rows( 1 ), selected columns( 0 ) );
/* End of Step 3 */</CODE></PRE><P><BR /><BR /></P>Sat, 13 Oct 2018 09:33:57 GMThttps://community.jmp.com/t5/Discussions/Value-selection-and-copy-into-new-columns/m-p/78875#M36593Pacco2018-10-13T09:33:57Z