dt = Open ("$ SAMPLE_DATA / Big Class.jmp");
//1.Wie man erkennt, wenn das Alter <12 ist, dann ändere: Alterswert auf "klein", anderer Wert in: Alter behalte keine Änderung
//2.wie man erkennt, dass man "-ABC" zu: name hinzufügt, damit sich die gesamte Spalte beispielsweise in "KATIE-ABC" ändert.
// wie man dann erkennt, dass der: Name durch "-" geteilt wird, entferne die Buchstaben nach "-" "
//3. Wie erkennt man, wenn: Größe> 60 und Gewicht Wert hat! = leer, dann ändert sich der Alterswert auf "Ja", andere Alterswerte ändern sich nicht.
//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"
)
);