Col Rank
Col Rank using Row
Example 1
Summary: Runs data manipulation by iterating over a list of variables and performing conditional actions to populate an empty table.
Code:
dt = Open("data_table.jmp");
Row() = 5;
xlist = {"1", "2", "3", "4"};
testVar = {};
For( i = 1, i <= N Items( xlist ), i++,
y = "sex";
If( i == 3, y = "height" );
Match( xlist[i],
xlist[1], Insert Into( testVar, Eval List( {i, y} ) ),
xlist[2], Insert Into( testVar, Eval List( {i, y} ) ),
xlist[3], Insert Into( testVar, Eval List( {i, y, Col Rank( Column( dt, Eval( y ) ) )} ) ),
xlist[4], Insert Into( testVar, Eval List( {i, y} ) ),
Insert Into( testVar, Eval List( {i, y, "error"} ) )
);
);
Code Explanation:
- Open data table.
- Set current row to 5.
- Define variable list
xlist. - Initialize empty list
testVar. - Start loop for each item in
xlist. - Set
yto "sex". - Change
yto "height" if index is 3. - Match item in
xlistand perform actions. - Insert values into
testVarbased on match. - End loop.
Example 2
Summary: Runs data table manipulation by iterating through a list of variables and inserting values into a test variable, utilizing MatchMZ and Insert Into functions.
Code:
dt = Open("data_table.jmp");
Row() = 5;
xlist = {"1", "2", "3", "4"};
testVar = {};
For( i = 1, i <= N Items( xlist ), i++,
y = "sex";
If( i == 3, y = "height" );
MatchMZ( xlist[i],
xlist[1], Insert Into( testVar, Eval List( {i, y} ) ),
xlist[2], Insert Into( testVar, Eval List( {i, y} ) ),
xlist[3], Insert Into( testVar, Eval List( {i, y, Col Rank( Column( dt, Eval( y ) ) )} ) ),
xlist[4], Insert Into( testVar, Eval List( {i, y} ) ),
Insert Into( testVar, Eval List( {i, y, "error"} ) )
);
);
Code Explanation:
- Open data table.
- Set row index.
- Define variable list.
- Initialize test variable.
- Start loop through list.
- Set default column name.
- Change column name for specific iteration.
- Match current list item.
- Insert values into test variable.
- End loop.
Example 3
Summary: Runs data matching and insertion into a test variable based on a predefined list of values, utilizing the MatchV3 function.
Code:
dt = Open("data_table.jmp");
Row() = 5;
xlist = {"1", "2", "3", "4"};
testVar = {};
For( i = 1, i <= N Items( xlist ), i++,
y = "sex";
If( i == 3, y = "height" );
MatchV3( xlist[i],
xlist[1], Insert Into( testVar, Eval List( {i, y} ) ),
xlist[2], Insert Into( testVar, Eval List( {i, y} ) ),
xlist[3], Insert Into( testVar, Eval List( {i, y, Col Rank( Column( dt, Eval( y ) ) )} ) ),
xlist[4], Insert Into( testVar, Eval List( {i, y} ) ),
Insert Into( testVar, Eval List( {i, y, "error"} ) )
);
);
Code Explanation:
- Open data table.
- Set row number.
- Define variable list.
- Initialize test variable.
- Loop through list items.
- Set y variable.
- Change y for third item.
- Match item and execute action.
- Insert into test variable.
- Repeat for all items.