<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: JSL: How to loop through columns, generate a Graph Builder report, and save each as a JPG file in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/189507#M40798</link>
    <description>&lt;P&gt;You could also replace the "For each row" section with a line to count the number of rows for each column.&amp;nbsp; This would utilize the datatable functions instead of needing to look through each row of each column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;COUNT_VAL=NROWS((DT&amp;lt;&amp;lt;SELECT WHERE(column(dt, Numeric Columns[i])[]&amp;lt;101))&amp;lt;&amp;lt;GET SELECTED ROWS);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2019 12:55:13 GMT</pubDate>
    <dc:creator>bfoulkes</dc:creator>
    <dc:date>2019-03-26T12:55:13Z</dc:date>
    <item>
      <title>JSL: How to loop through columns, generate a Graph Builder report, and save each as a JPG file</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/188826#M40752</link>
      <description>&lt;P&gt;I'm trying to create a script that can loop through each cell of each column to count the number of cells that are less or greater than a specified value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i have a table of columns A ~ D and Rows 1 ~ 10, I'd like to count the values of the cells row-wise and column-wise. In other word, for all rows of column A, how many meet my criteria. And similarly for all columns of Row 1, how many meet my criteria. I would then do this for all rows and columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what ive tried to start with, but it returns nothing. Any ideas on this or a more effcient way to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();
Clear Log();


// Get all of the numeric columns in the data table
Numeric Columns = dt &amp;lt;&amp;lt; get column names( numeric, string );
NRows = N Rows( dt );

Count = {};

//Column loop
For( i = 1, N Items( Numeric Columns ) &amp;lt;= 1, i++, 
	
	For Each Row(
		dt, 

		If( Column(dt, Numeric Columns[i]) &amp;lt; 101, 
			
			Count = Count++;
			Show( Count );
		) 
		 	
	)
		
	
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 13:01:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/188826#M40752</guid>
      <dc:creator>abdulj</dc:creator>
      <dc:date>2019-03-22T13:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: How to loop through columns, generate a Graph Builder report, and save each as a JPG file</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/188852#M40755</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2960"&gt;@abdulj&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; You could use matrices to identify conditions that you want to test against. Here is an example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Log(); 

// Open a sample data set 
dt = Open( "$SAMPLE_DATA/Cars.jmp" );

// Extracting numeric column names 
ColNames = dt &amp;lt;&amp;lt; Get Column Names("String");
NumericCols = []; 
for(nCol = 1, nCol &amp;lt;= N Items(ColNames), nCol++,
	DType = Column(dt,nCol) &amp;lt;&amp;lt; Get Data Type; 
	If(DType == "Numeric",
		NumericCols = NumericCols || nCol; 
	  );
   );   
NumericColNames = ColNames[NumericCols];

// Extract numeric data only
Mat = dt &amp;lt;&amp;lt; Get As Matrix; 

// Row Wise Test 
// For e.g. Find all rows where year &amp;lt; 90 
YearCondition = Loc(Mat[0,1] &amp;lt; 90); 

Show(Mat[YearCondition,0]); &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 14:46:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/188852#M40755</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2019-03-22T14:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: How to loop through columns, generate a Graph Builder report, and save each as a JPG file</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/188865#M40757</link>
      <description>&lt;P&gt;There are a few problems with the script that are easily fixed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. The test portion of the for loop is wrong:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="jsl"&gt;&lt;SPAN class="token function"&gt;N Items&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; Numeric Columns &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;The number of Numeric columns doesn't change. If there are 0 or 1 numeric columns, the loop will run forever because 0&amp;lt;=1 and 1&amp;lt;=1. If there are at least 2 numeric columns, then the loop doesn't run at all because 2(or more)&amp;lt;=1 is always false. The test should be this:&lt;/P&gt;
&lt;LI-CODE lang="jsl"&gt; i &amp;lt;= N Items( Numeric Columns )&lt;/LI-CODE&gt;
&lt;P&gt;That tests whether your iterator (i) is greater than the number of columns and stops when it is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; In a For Each Row loop, you still need to subscript into the row, you just don't have to manage the iteration yourself. So this piece:&lt;/P&gt;
&lt;LI-CODE lang="jsl"&gt;&lt;SPAN class="token function"&gt;Column&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dt&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; Numeric Columns&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;101&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;Should look like this:&lt;/P&gt;
&lt;LI-CODE lang="jsl"&gt;&lt;SPAN class="token function"&gt;Column&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dt&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; Numeric Columns&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)[Row()]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;101&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;3. Your Count variable is a list, but you're treating it like a number. Count++ doesn't do anything to a list that isn't populated with numbers. Set Count = 0 instead of Count = {}. Additionally, Count++ returns the current value, and then sets Count to Count +1. So Count = Count++ will never change the value of Count. (Example: Count = 0. Count = Count++. Count is still equal to zero.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the full script with the changes above. The end Count is the number of cells in all numeric columns that are less than 101.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();
Clear Log();


// Get all of the numeric columns in the data table
Numeric Columns = dt &amp;lt;&amp;lt; get column names( numeric, string );
NRows = N Rows( dt );

Count = 0;

//Column loop
For( i = 1, i &amp;lt;= N Items( Numeric Columns ), i++, 
	
	For Each Row(
		dt, 

		If( Column(dt, Numeric Columns[i])[Row()] &amp;lt; 101, 
			
			Count++;
			Show( Count );
		) 
		 	
	)
		
	
);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Melanie&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 15:14:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/188865#M40757</guid>
      <dc:creator>Melanie_J_Drake</dc:creator>
      <dc:date>2019-03-22T15:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: How to loop through columns, generate a Graph Builder report, and save each as a JPG file</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/189507#M40798</link>
      <description>&lt;P&gt;You could also replace the "For each row" section with a line to count the number of rows for each column.&amp;nbsp; This would utilize the datatable functions instead of needing to look through each row of each column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;COUNT_VAL=NROWS((DT&amp;lt;&amp;lt;SELECT WHERE(column(dt, Numeric Columns[i])[]&amp;lt;101))&amp;lt;&amp;lt;GET SELECTED ROWS);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 12:55:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-How-to-loop-through-columns-generate-a-Graph-Builder-report/m-p/189507#M40798</guid>
      <dc:creator>bfoulkes</dc:creator>
      <dc:date>2019-03-26T12:55:13Z</dc:date>
    </item>
  </channel>
</rss>

