dt = 열기 ( "$ SAMPLE_DATA / Big Class.jmp");
// 1. 나이가 12 세 미만인 경우 인식하는 방법 : : age 값을 "small"로 변경하고 : age의 다른 값은 변경되지 않음
// 2. "-ABC"를 : name에 추가하여 전체 열이 "KATIE-ABC"로 변경되도록하는 방법
// : : name을 "-"로 나누면 "-" "뒤의 문자를 제거하는 방법
//삼. : height> 60이고 체중에 값이! = 공백인지, 연령 값이 "예"로 변경되는지 여부를 인식하는 방법, 연령의 다른 값은 변경되지 않습니다.
//1.how to realize if age<12, then change :age
// value to "small", other value in :age keep no change
names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << set name("Example 1a");
// Use the Value Labels column property to change the
// displayed value, while not changing the actual value
dt:age << set property("value Labels", {12 = "small"});
dt << Oneway( x(:age), y(:height));
//1.how to realize if age<12, then change :age
// value to "small", other value in :age keep no change
names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << set name("Example 1b");
// Change the actual value of 12 to "small"
// Since the column Age is a numeric column, it will
// have to be changed to Data Type Character before
// the value can be changed
dt:age << data type(character);
// Now the vlaue can be changed
// The age value in :age == "12" has to be in
// double quotes, since the age column has been
// changed to data type character
dt:age[dt<<GET rows="" where=""></GET>
//2.how to realize that add "-ABC" to :name
// to let the whole column change to for
// example "KATIE-ABC"
//then how to realize that split the :name by "-",
// remove the letters after "-""
names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << set name("Example 2");
// To add the characters to each value of :Name
// just requires a simple For Each Row() with
// a concatenation of "-ABC" to each value
For Each Row(
dt:Name = dt:Name || "-ABC"
);
// To find the "-" and to get rid of the "-ABC"
// is easily done with a Word() function
// It allows one to parse strings into "words"
// based upon designated delimiters
For Each Row(
dt:Name = Word(1, :Name, "-" )
);
// The removal of the values after finding the
// "-" can also be accomplished using either
// a Left() function or a Substr() function
// using the returned value from a Contains()
// function to determine where the "-" is
/*For Each Row(
dt:Name = left(dt:Name,contains(dt:Name,"-") -1 )
);
// or
For Each Row(
dt:Name = Substr(dt:Name,1, contains(dt:Name,"-") -1 )
);*/
//3. how to realize if :height>60, and weight
// has value !=blank, then age value change
// to "Yes", other value in age keep no change.
names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << set name("Example 3");
// Set the value of JACLYN's weight to missing
// to allow for the test case, where the
// :Height is greater than 60, but the :Weight
// is missing
dt:Weight[4] = .;
// Since the column :height is numeric and a
// character value of "Yes" is to be placed in
// that column, the column needs to be changed
// to Data Type of Character
dt:Height << data type(character);
// Now a For Each Row() with a two level
// comparison can be used to change the
// described value
For Each Row(
If( :Height > "60" & isMissing( :Weight ) == 0,
:Height = "Yes"
)
);