cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
%3CLINGO-SUB%20id%3D%22lingo-sub-781042%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%A6%82%E4%BD%95%E8%AE%A1%E7%AE%97%E7%89%B9%E5%AE%9A%E8%A1%8C%E4%B8%AD%E7%9A%84%E9%9D%9E%E7%A9%BA%E8%A1%8C%E6%95%B0%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-781042%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E6%88%91%E6%9C%89%E6%AD%A4%E5%A4%84%E6%98%BE%E7%A4%BA%E7%9A%84%E8%A1%A8%E6%A0%BC%EF%BC%8C%E5%B9%B6%E6%83%B3%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E5%8C%85%E5%90%AB%E2%80%9CN%E2%80%9D%E7%9A%84%E6%96%B0%E5%88%97%EF%BC%8C%E8%AF%A5%E5%88%97%E6%98%AF%E5%B8%A6%E6%9C%89%E6%95%B0%E5%AD%97%E7%9A%84%E5%88%97%E6%95%B0%EF%BC%8C%E4%BD%86%E4%BB%85%E9%99%90%E4%BA%8E%E6%A0%87%E8%AE%B0%E4%B8%BA%E2%80%9CDecodeCount_BW**%E2%80%9D%E7%9A%84%E5%88%97%E3%80%82%E4%BE%8B%E5%A6%82%EF%BC%8C%E5%AF%B9%E4%BA%8E%E7%AC%AC%E4%B8%80%E8%A1%8C%EF%BC%8C%E5%AE%83%E5%BA%94%E8%AF%A5%E8%BF%94%E5%9B%9E%E2%80%9C5%E2%80%9D%EF%BC%8C%E5%AF%B9%E4%BA%8E%E7%AC%AC%E4%BA%8C%E8%A1%8C%EF%BC%8C%E5%AE%83%E5%BA%94%E8%AF%A5%E8%BF%94%E5%9B%9E%E2%80%9C2%E2%80%9D%EF%BC%8C%E7%AD%89%E7%AD%89%3C%2FP%3E%3CP%3E%E5%9C%A8%20Excel%20%E4%B8%AD%EF%BC%8C%E6%88%91%E4%BD%BF%E7%94%A8%E2%80%9Ccounta%E2%80%9D%E6%9D%A5%E6%89%A7%E8%A1%8C%E6%AD%A4%E6%93%8D%E4%BD%9C%EF%BC%8C%E4%BD%86%E5%B0%9D%E8%AF%95%E5%AD%A6%E4%B9%A0%20JMP%20%E4%BB%A5%E6%94%B9%E8%BF%9B%E7%BB%9F%E8%AE%A1%E5%88%86%E6%9E%90%EF%BC%8C%E4%BD%86%E6%88%91%E8%A2%AB%E5%9B%B0%E5%9C%A8%E8%BF%99%E6%A0%B7%E7%AE%80%E5%8D%95%E7%9A%84%E4%BA%8B%E6%83%85%E4%B8%8A%EF%BC%8C%E8%BF%99%E5%8F%AF%E8%83%BD%E6%98%AF%E5%9B%A0%E4%B8%BA%E6%88%91%E7%9A%84%E5%A4%A7%E8%84%91%E6%98%AF%20Excel%20%E6%A0%BC%E5%BC%8F%E7%9A%84...%E6%8A%B1%E6%AD%89%EF%BC%8C%E5%A6%82%E6%9E%9C%E8%BF%99%E6%98%AF%E9%9D%9E%E5%B8%B8%E5%9F%BA%E7%A1%80%E7%9A%84%EF%BC%8C%E4%BD%86%E6%88%91%E6%89%BE%E4%B8%8D%E5%88%B0%E5%9C%A8%E5%85%AC%E5%BC%8F%E5%88%97%E8%A1%A8%E4%B8%AD%E6%89%A7%E8%A1%8C%E6%AD%A4%E6%93%8D%E4%BD%9C%E7%9A%84%E5%85%AC%E5%BC%8F..%3C%2FP%3E%3CP%3E%E8%B0%A2%E8%B0%A2%3C%2FP%3E%3CP%3EJMP17%20%E7%94%A8%E6%88%B7%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-781042%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3E%E5%86%85%E5%AE%B9%E7%BB%84%E7%BB%87%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%E6%95%B0%E6%8D%AE%E6%B7%B7%E5%90%88%E5%92%8C%E6%B8%85%E7%90%86%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-781079%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E5%A6%82%E4%BD%95%E8%AE%A1%E7%AE%97%E7%89%B9%E5%AE%9A%E8%A1%8C%E4%B8%AD%E7%9A%84%E9%9D%9E%E7%A9%BA%E8%A1%8C%E6%95%B0%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-781079%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%85%AC%E5%BC%8F%E9%80%9A%E5%B8%B8%E4%B8%8D%E5%A4%AA%E5%AE%B9%E6%98%93%E5%9C%A8%E8%BF%99%E4%B8%AA%E6%96%B9%E5%90%91%E4%B8%8A%E8%B5%B7%E4%BD%9C%E7%94%A8%EF%BC%88%E6%8C%89%E8%A1%8C%E8%80%8C%E4%B8%8D%E6%98%AF%E6%8C%89%E5%88%97%E8%AE%A1%E7%AE%97%EF%BC%89%E3%80%82%E6%A0%B9%E6%8D%AE%E4%BD%A0%E6%AD%A3%E5%9C%A8%E5%81%9A%E7%9A%84%E4%BA%8B%E6%83%85%EF%BC%8C%E5%85%88%E5%A0%86%E5%8F%A0%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%83%BD%E4%BC%9A%E6%9C%89%E6%89%80%E5%B8%AE%E5%8A%A9%E3%80%82%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%E4%BD%A0%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E5%85%AC%E5%BC%8F%EF%BC%88%E5%8F%AF%E8%83%BD%E6%9C%89%E7%82%B9%E9%BA%BB%E7%83%A6%EF%BC%89%EF%BC%8C%E4%BD%86%E4%B8%80%E8%88%AC%E6%88%91%E4%BC%9A%E4%BD%BF%E7%94%A8%E8%84%9A%E6%9C%AC%E3%80%82%E4%B8%8B%E9%9D%A2%E6%98%AF%E4%B8%80%E4%B8%AA%E4%BE%8B%E5%AD%90%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_0-1723483606619.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1723483606619.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1723483606619.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67065iC98BBC30F59E15BC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jthi_0-1723483606619.png%22%20alt%3D%22jthi_0-1723483606619.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adt%20%3D%20New%20Table(%22Untitled%203%22%2C%0A%09Add%20Rows(3)%2C%0A%09Compress%20File%20When%20Saved(1)%2C%0A%09New%20Column(%22Column%201%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Set%20Values(%5B.%2C%20.%2C%20.%5D))%2C%0A%09New%20Column(%22Column%202%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Set%20Values(%5B.%2C%20.%2C%20.%5D))%2C%0A%09New%20Column(%22AB1%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Set%20Values(%5B2%2C%20.%2C%20.%5D))%2C%0A%09New%20Column(%22AB2%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Set%20Values(%5B.%2C%202%2C%201%5D))%2C%0A%09New%20Column(%22AB3%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Set%20Values(%5B.%2C%205%2C%20.%5D))%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22N%22%2C%20Numeric%2C%20Continuous)%3B%0A%0Acols_of_interest%20%3D%20Filter%20Each(%7Bcolname%7D%2C%20dt%20%26lt%3B%26lt%3B%20Get%20Column%20Names(%22String%22)%2C%0A%09Starts%20With(colname%2C%20%22AB%22)%3B%0A)%3B%0A%0AFor%20Each%20Row(Current%20Data%20Table()%2C%0A%09%3AN%20%3D%20Sum(!Is%20Missing(dt%5BRow()%2C%20cols_of_interest%5D))%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%E5%A6%82%E6%9E%9C%E4%BD%A0%E7%9C%9F%E7%9A%84%E6%83%B3%E4%BD%BF%E7%94%A8%E5%85%AC%E5%BC%8F%EF%BC%8C%E4%BD%A0%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E7%B1%BB%E4%BC%BC%E8%BF%99%E6%A0%B7%E7%9A%84%E6%96%B9%E6%B3%95%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EAs%20Constant(cols_of_interest%20%3D%20Filter%20Each(%7Bcolname%7D%2C%20Current%20Data%20Table()%20%26lt%3B%26lt%3B%20Get%20Column%20Names(%22String%22)%2C%0A%09Starts%20With(colname%2C%20%22AB%22)%3B%0A))%3B%0ASum(!Is%20Missing(dt%5BRow()%2C%20cols_of_interest%5D))%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%E6%82%A8%E5%BF%85%E9%A1%BB%E8%87%AA%E5%B7%B1%E8%AE%A1%E7%AE%97%E6%AF%94%E8%BE%83%E7%BB%93%E6%9E%9C%EF%BC%8C%E4%BB%A5%E7%AD%9B%E9%80%89%E5%87%BA%E6%82%A8%E6%84%9F%E5%85%B4%E8%B6%A3%E7%9A%84%E5%88%97%EF%BC%88Starts%20With%20%E4%B9%9F%E9%80%82%E7%94%A8%E4%BA%8E%E6%82%A8%E7%9A%84%E6%95%B0%E6%8D%AE%EF%BC%89%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-781081%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E5%A6%82%E4%BD%95%E8%AE%A1%E7%AE%97%E7%89%B9%E5%AE%9A%E8%A1%8C%E4%B8%AD%E7%9A%84%E9%9D%9E%E7%A9%BA%E8%A1%8C%E6%95%B0%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-781081%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E8%A1%A8%E6%A0%BC%2F%E6%91%98%E8%A6%81%E5%8F%AF%E4%BB%A5%E4%B8%BA%E6%82%A8%E8%AE%A1%E6%95%B0%E3%80%82%E8%A6%81%E4%BD%BF%E5%85%B6%E8%AE%A1%E6%95%B0%E5%88%B0%E5%A4%9A%E5%88%97%EF%BC%8C%E6%82%A8%E5%BF%85%E9%A1%BB%E5%85%88%E5%A0%86%E5%8F%A0%E6%95%B0%E6%8D%AE%EF%BC%9A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20New%20Table(%20%22test%22%2C%0A%09Add%20Rows(%206%20)%2C%0A%09New%20Column(%20%22W8%22%2CSet%20Values(%20%5B2%2C%205%2C%20.%2C%205%2C%20.%2C%206%5D%20))%2C%0A%09New%20Column(%20%22W9%22%2CSet%20Values(%20%5B2%2C%20.%2C%203%2C%203%2C%201%2C%202%5D%20))%2C%0A%09New%20Column(%20%22W1%22%2CSet%20Values(%20%5B2%2C%20.%2C%20.%2C%20.%2C%20.%2C%20.%5D%20))%2C%0A%09New%20Column(%20%22W2%22%2CSet%20Values(%20%5B3%2C%20.%2C%20.%2C%20.%2C%20.%2C%20.%5D%20))%2C%0A%09New%20Column(%20%22W3%22%2CSet%20Values(%20%5B3%2C%20.%2C%20.%2C%20.%2C%20.%2C%20.%5D%20))%2C%0A%09New%20Column(%20%22W4%22%2CSet%20Values(%20%5B.%2C%20.%2C%204%2C%20.%2C%202%2C%20.%5D%20))%2C%0A%09New%20Column(%20%22W5%22%2CSet%20Values(%20%5B.%2C%202%2C%20.%2C%20.%2C%20.%2C%20.%5D%20))%2C%0A%09New%20Column(%20%22W6%22%2CSet%20Values(%20%5B.%2C%20.%2C%205%2C%20.%2C%203%2C%20.%5D%20)))%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22row%22%2CFormula(%20Row()%20))%3B%0Adtstack%20%3Ddt%20%26lt%3B%26lt%3B%20Stack(%09columns(%20%3AW8%2C%20%3AW9%2C%20%3AW1%2C%20%3AW2%2C%20%3AW3%2C%20%3AW4%2C%20%3AW5%2C%20%3AW6%20)%2C%22Non-stacked%20columns%22n(%20Keep(%20%3Arow%20)%20))%3B%0Adtstack%20%26lt%3B%26lt%3B%20Summary(%09Group(%20%3Arow%20)%2C%09N(%20%3AData%20)%09)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%E9%A1%BA%E4%BE%BF%E6%8F%90%E4%B8%80%E5%8F%A5%EF%BC%9A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%22Non-stacked%20columns%22n%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E4%B8%80%E4%B8%AA%E5%91%BD%E5%90%8D%E5%8F%82%E6%95%B0%EF%BC%8C%E9%9C%80%E8%A6%81%E5%86%99%E6%88%90%3CFONT%20face%3D%22courier%20new%2Ccourier%22%3E%E2%80%9C...%E2%80%9Dn%3C%2FFONT%3E%20%E3%80%82%E5%95%8A%EF%BC%81%3C%2FP%3E%3CP%3E%E5%A2%9E%E5%BC%BA%E6%97%A5%E5%BF%97%E5%A6%82%E4%BD%95%E7%9F%A5%E9%81%93%E8%BF%99%E4%BA%9B%E7%BB%86%E8%8A%82......%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar

How do I count number of non-blank rows across specific rows?

I have the table displayed here and would like to make a new column that contains "N" which is the number of columns that have numbers but only for the columns labelled "DecodeCount_BW**". For example for the first row, it should return "5", for the second row it should return "2", etc

In Excel I do this with "counta", but trying to learn JMP for improved statistical analysis, but I've getting stuck at simple things like this maybe due to my excel-formatted brain... Sorry if this is super basic but I can't find a formula on the list of formulas that does this..

Thanks

JMP17 user

2 REPLIES 2
jthi
Super User

Re: How do I count number of non-blank rows across specific rows?

Formulas generally do not work in this direction that easily (calculating something by row instead of column). Depending what you are doing stacking your data first might be beneficial.

 

You can use formula for that (it might be a bit finicky), but generally I would use scripting. Below is one example

jthi_0-1723483606619.png

 

Names Default To Here(1);

dt = New Table("Untitled 3",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
	New Column("AB1", Numeric, "Continuous", Format("Best", 12), Set Values([2, ., .])),
	New Column("AB2", Numeric, "Continuous", Format("Best", 12), Set Values([., 2, 1])),
	New Column("AB3", Numeric, "Continuous", Format("Best", 12), Set Values([., 5, .]))
);

dt << New Column("N", Numeric, Continuous);

cols_of_interest = Filter Each({colname}, dt << Get Column Names("String"),
	Starts With(colname, "AB");
);

For Each Row(Current Data Table(),
	:N = Sum(!Is Missing(dt[Row(), cols_of_interest]));
);

and if you really want to use formula you might be able to use something like this

As Constant(cols_of_interest = Filter Each({colname}, Current Data Table() << Get Column Names("String"),
	Starts With(colname, "AB");
));
Sum(!Is Missing(dt[Row(), cols_of_interest]));

You have to figure your own comparison to filter down to columns of interest (Starts With should work for your data also)

-Jarmo
hogi
Level XII

Re: How do I count number of non-blank rows across specific rows?

Tables/Summary can count for you. To make it count over multiple columns, you have to fist stack the data:

dt = New Table( "test",
	Add Rows( 6 ),
	New Column( "W8",Set Values( [2, 5, ., 5, ., 6] )),
	New Column( "W9",Set Values( [2, ., 3, 3, 1, 2] )),
	New Column( "W1",Set Values( [2, ., ., ., ., .] )),
	New Column( "W2",Set Values( [3, ., ., ., ., .] )),
	New Column( "W3",Set Values( [3, ., ., ., ., .] )),
	New Column( "W4",Set Values( [., ., 4, ., 2, .] )),
	New Column( "W5",Set Values( [., 2, ., ., ., .] )),
	New Column( "W6",Set Values( [., ., 5, ., 3, .] )));

dt << New Column( "row",Formula( Row() ));
dtstack =dt << Stack(	columns( :W8, :W9, :W1, :W2, :W3, :W4, :W5, :W6 ),"Non-stacked columns"n( Keep( :row ) ));
dtstack << Summary(	Group( :row ),	N( :Data )	);

 

btw:

"Non-stacked columns"n

a named argument which needs to be written as  "..."n. Argh!

How good that enhanced log knows these details ...