cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-866685%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%B0%8B%E6%89%BE%E7%BC%BA%E5%B0%91%E5%BE%9E%20X%20%E5%88%97%E9%96%8B%E5%A7%8B%E7%9B%B4%E5%88%B0%20ncol()%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-866685%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%EF%BC%8C%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%E6%88%91%E6%9C%89%E4%B8%80%E5%BC%B5%E5%8C%85%E5%90%AB%E6%95%B8%E5%8D%83%E5%88%97%E7%9A%84%E8%A1%A8%E3%80%82%E6%88%91%E6%83%B3%E4%BD%BF%E7%94%A8%E5%88%97%E7%9F%A9%E9%99%A3%E4%BE%86%E5%B0%8B%E6%89%BE%E4%B8%80%E7%B3%BB%E5%88%97%E5%88%97%E6%98%AF%E5%90%A6%E7%BC%BA%E5%A4%B1%E3%80%82%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%E6%88%91%E5%85%88%E4%BD%BF%E7%94%A8%20Loc()%20%E4%BE%86%E6%B1%BA%E5%AE%9A%E7%AC%AC%E4%B8%80%E5%80%8B%E5%88%97%E8%99%9F%E7%9A%84%E8%B5%B7%E5%A7%8B%E3%80%82%3C%2FP%3E%0A%3CP%3Eallcol%20%3D%20dt%20%26lt%3B%26lt%3B%20%E5%8F%96%E5%BE%97%E5%88%97%E5%90%8D%EF%BC%88%E5%AD%97%E4%B8%B2%EF%BC%89%EF%BC%9B%3C%2FP%3E%0A%3CP%3Ecolname%20%3D%20column%20(%22%E8%B5%B7%E5%A7%8B%E5%88%97%22)%20%26lt%3B%26lt%3B%20getname%3B%3C%2FP%3E%0A%3CP%3E%E5%88%97%E8%99%9F%20%3D%20(Loc(allcol%2C%E5%88%97%E5%90%8D))%5B1%5D%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%E7%84%B6%E5%BE%8C%E6%88%91%E6%83%B3%E6%9F%A5%E6%89%BE%E5%BE%9E%20colnumber%20%E5%88%B0%20ncol()%20%E7%9A%84%E5%88%97%E6%98%AF%E5%90%A6%E7%BC%BA%E5%A4%B1%E3%80%82%E9%A1%9E%E4%BC%BC%E4%B8%8B%E9%9D%A2%E7%9A%84%E6%93%8D%E4%BD%9C%E4%BD%86%E5%A4%B1%E6%95%97%E4%BA%86%E3%80%82%E6%9C%89%E4%BA%BA%E8%83%BD%E5%91%8A%E8%A8%B4%E6%88%91%E8%A9%B2%E5%A6%82%E4%BD%95%E5%81%9A%E5%B0%8D%E5%97%8E%EF%BC%9F%3C%2FP%3E%0A%3CP%3Edt%20%26lt%3B%26lt%3B%20%E9%81%B8%E6%93%87%E5%85%B6%E4%B8%AD%EF%BC%88ismissing%EF%BC%88column%EF%BC%88%EF%BC%89%5Bcolnumber%20%3A%3A%20ncol%EF%BC%88%EF%BC%89%5D%EF%BC%89%EF%BC%89%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-866685%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3E%E8%87%AA%E5%8B%95%E5%8C%96%E5%92%8C%E8%85%B3%E6%9C%AC%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-866706%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%B0%8B%E6%89%BE%E7%BC%BA%E5%B0%91%E5%BE%9E%20X%20%E5%88%97%E9%96%8B%E5%A7%8B%E7%9B%B4%E5%88%B0%20ncol()%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-866706%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BB%A5%E4%B8%8B%E6%98%AF%E6%89%BE%E5%87%BA%E6%AF%8F%E5%80%8B%E8%A1%8C%E5%88%97%E7%AF%84%E5%9C%8D%E5%85%A7%E6%9C%89%E7%BC%BA%E5%A4%B1%E5%80%BC%E7%9A%84%E8%A1%8C%E7%9A%84%E7%AF%84%E4%BE%8B%E3%80%82%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20%0A%2F%2F%20Open%20Data%20Table%3A%20semiconductor%20capability.jmp%0A%2F%2F%20%E2%86%92%20Data%20Table(%20%22semiconductor%20capability%22%20)%0AOpen(%20%22%24SAMPLE_DATA%2Fsemiconductor%20capability.jmp%22%20)%3B%0A%2F%2F%20for%20example%20purposes%20set%20some%20random%20cells%20to%20missing%20values%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20Random%20Integer(%201%2C%20100%20)%2C%20i%2B%2B%2C%0A%09random%20row%20%3D%20Random%20Integer(%201%2C%201455%20)%3B%0A%09random%20col%20%3D%20Random%20Integer(%205%2C%20132%20)%3B%0A%09dt%5Brandom%20row%2C%20random%20col%5D%20%3D%20.%3B%0A)%3B%0A%0Astarting%20colName%20%3D%20%22NPN1%22%3B%0Aallcol%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(%20string%20)%3B%0Astarting%20col%20%3D%20Contains(%20allcol%2C%20starting%20colName%20)%3B%0ArowsWithMissing%20%3D%20%5B%5D%3B%0A%0AFor%20Each%20Row(%0A%09mat%20%3D%20dt%5BRow()%2C%20starting%20col%20%3A%3A%20N%20Col(%20dt%20)%5D%3B%0A%09If(%20Length(%20Loc(%20mat%2C%20.%20)%20)%20%26gt%3B%200%2C%0A%09%09rowsWithMissing%20%3D%20rowsWithMissing%20%7C%7C%20matrix(row())%3B%0A%09)%3B%0A)%3B%0Ashow(rowsWithMissing)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
dadawasozo
Level IV

find is missing start from column X till ncol()

Hi,

 

I have a table that has thousand of columns. I want to use column matrix to find if across a range of columns is missing.

 

I first identify the starting of the first column number using Loc().

allcol = dt << get column names(string);

colname = column ("starting column") << getname;

colnumber =  (Loc(allcol ,colname))[1];

 

then I want to find if the columns from colnumber till ncol() is missing.  something like below but it failed. can someone point me how I can make it right ? 

dt << select where (ismissing(column()[colnumber :: ncol()]))

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: find is missing start from column X till ncol()

Here is an example of finding rows that have missing values within a range of columns for each row.

Names Default To Here( 1 );
dt = 
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
// for example purposes set some random cells to missing values
For( i = 1, i <= Random Integer( 1, 100 ), i++,
	random row = Random Integer( 1, 1455 );
	random col = Random Integer( 5, 132 );
	dt[random row, random col] = .;
);

starting colName = "NPN1";
allcol = dt << get column names( string );
starting col = Contains( allcol, starting colName );
rowsWithMissing = [];

For Each Row(
	mat = dt[Row(), starting col :: N Col( dt )];
	If( Length( Loc( mat, . ) ) > 0,
		rowsWithMissing = rowsWithMissing || matrix(row());
	);
);
show(rowsWithMissing);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: find is missing start from column X till ncol()

Here is an example of finding rows that have missing values within a range of columns for each row.

Names Default To Here( 1 );
dt = 
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
// for example purposes set some random cells to missing values
For( i = 1, i <= Random Integer( 1, 100 ), i++,
	random row = Random Integer( 1, 1455 );
	random col = Random Integer( 5, 132 );
	dt[random row, random col] = .;
);

starting colName = "NPN1";
allcol = dt << get column names( string );
starting col = Contains( allcol, starting colName );
rowsWithMissing = [];

For Each Row(
	mat = dt[Row(), starting col :: N Col( dt )];
	If( Length( Loc( mat, . ) ) > 0,
		rowsWithMissing = rowsWithMissing || matrix(row());
	);
);
show(rowsWithMissing);
Jim

Recommended Articles