Explanation: The LENGTH statement specifies that the variable city has a length of 20 characters. The TRIM function in the assignment statement for city2 removes trailing blanks from the value. However, the length of the city2 variable is set to 20 because city has a length of 20, and SAS pads the trimmed value with extra blanks.
[Trim just deleting the space, but still the same variable lenth] - Variable length character is determined by its location and the first occurrence of the statement where the decision. 1 if the statement in length, its length is the length of the statement is assigned to the variable length; (2) If the list INPUT statement, and there is no specified length, then use the default length of 8; (3) If the SET statement (in their data set in the SET statement), the length of the variable in the data set that is its length; 4 If the first occurrence of a string is assigned to the variable, the variable length is the length of the string; 5 If it is the result of a function assigned to this variable, that variable length is to be determined according to the function. Such as the use trim (), substr (), then use the first parameter is a variable length length; such as using put (), then the length of the variable is equal to the length of format; while repeat () function will set the default variable length 200; etc.
Which one of the following statements completes the program and adds the values of salary and raise to calculate the expected values of the newsalary variable?
Explanation: You must convert the value of salary from character to numeric in order to perform an arithmetic function on it. You use the INPUT function to convert a character value to a numeric value.
The following SAS program is submitted:
data work.travel; do i=1 to 6 by 2; trip + i;end; run;
Question : Which one of the following is the value of the variable trip in the output data set?
Explanation: The sum variable in a sum statement is automatically set to 0 before the first observation is read from the data set. The sum variable in the statement above is increased by the value of i on each iteration of the DO loop; the value of i is set to 1 on the first iteration of the DO loop and increases by 2 on each additional iteration until it is greater than 6. Therefore, the value ofTripis equal to 0 + 1 + 3 + 5, which is 9.