<?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: counting character columns in jsl in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374674#M62446</link>
    <description>&lt;P&gt;A formula is all you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="formula.PNG" style="width: 802px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31905i88134258E1E72EFD/image-size/large?v=v2&amp;amp;px=999" role="button" title="formula.PNG" alt="formula.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="table.PNG" style="width: 721px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31906i1AD55B046AB63CD7/image-size/large?v=v2&amp;amp;px=999" role="button" title="table.PNG" alt="table.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Apr 2021 17:15:51 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2021-04-06T17:15:51Z</dc:date>
    <item>
      <title>counting character columns in jsl</title>
      <link>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374655#M62444</link>
      <description>&lt;P&gt;I have a data table with several data columns with binary 0/1 responses (character, nominal). I want to create a new column (numerical, continuous) where I am counting the instances of "1"s in these columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can someone help me create a script to create this column? I feel like this should be easy but I am running into road blocks. Do I have to convert my character columns to numerical/continuous columns and do summation formula?&amp;nbsp; Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example table&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;infection (character, nominal)&lt;/TD&gt;&lt;TD&gt;blood clot (character, nominal)&lt;/TD&gt;&lt;TD&gt;surgery (character, nominal)&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;NEW COLUMN:&lt;/P&gt;&lt;P&gt;number of complications (numerical, continuous)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:10:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374655#M62444</guid>
      <dc:creator>ERobison</dc:creator>
      <dc:date>2023-06-09T22:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: counting character columns in jsl</title>
      <link>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374674#M62446</link>
      <description>&lt;P&gt;A formula is all you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="formula.PNG" style="width: 802px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31905i88134258E1E72EFD/image-size/large?v=v2&amp;amp;px=999" role="button" title="formula.PNG" alt="formula.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="table.PNG" style="width: 721px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31906i1AD55B046AB63CD7/image-size/large?v=v2&amp;amp;px=999" role="button" title="table.PNG" alt="table.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 17:15:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374674#M62446</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2021-04-06T17:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: counting character columns in jsl</title>
      <link>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374679#M62447</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;&amp;nbsp;provided a good solution&lt;/P&gt;
&lt;P&gt;Here is another way to do solve the problem&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
charNames = dt &amp;lt;&amp;lt; get column names( character );

// convert char columns to numeric
For( i = 1, i &amp;lt;= N Items( charNames ), i++,
	Column( dt, charNames[i] ) &amp;lt;&amp;lt; data type( numeric )
);

// Create the jsl required to sum all of the specified columns
theExpr = "dt &amp;lt;&amp;lt; new column(\!"number of complications\!", formula(sum(" ||
Substr( Char( charnames ), 2, Length( Char( charNames ) ) - 2 ) || "));";

// Execute the line of code created
Eval( Parse() );

// Delete the formula leaving the static values
Column( dt, "number of complications" ) &amp;lt;&amp;lt; delete formula;

// Convert the binary columns back to character
For( i = 1, i &amp;lt;= N Items( charNames ), i++,
	Column( dt, charNames[i] ) &amp;lt;&amp;lt; data type( character )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Apr 2021 17:52:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374679#M62447</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-04-06T17:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: counting character columns in jsl</title>
      <link>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374898#M62459</link>
      <description>&lt;P&gt;Thanks to both&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;for providing two approaches to my problem. I am going to go with the script as I am trying to create a full script for my data table creation to be used again in the future.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 14:00:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/counting-character-columns-in-jsl/m-p/374898#M62459</guid>
      <dc:creator>ERobison</dc:creator>
      <dc:date>2021-04-07T14:00:35Z</dc:date>
    </item>
  </channel>
</rss>

