Explanation: Because the YEARCUTOFF= system option is set to 1920, SAS sees the two-digit year value 20 as 1920. Four-digit year values are always read correctly. Syntax :MDY(month,day,year) Required Arguments month : specifies a numeric constant, variable, or expression that represents an integer from 1 through 12. day : specifies a numeric constant, variable, or expression that represents an integer from 1 through 31. year : specifies a numeric constant, variable, or expression with a value of a two-digit or four-digit integer that represents the year. The YEARCUTOFF= system option defines the year value for two-digit dates.
Example The following SAS statements produce these results.
SAS Statement
birthday=mdy(8,27,90); put birthday; put birthday= worddate.;
Result
birthday=August 27, 1990
SAS Statement anniversary=mdy(7,11,2001); put anniversary; put anniversary=date9.;
Result anniversary=11JUL2001
Question : The variable Address contains values such as Newdelhidl, DL. How do you assign the two-letter state abbreviations to a new variable named Capital? 1. Capital=scan(address2,2); 2. Capital=scan(address2,13,2); 3. Capital=substr(address2,2); 4. Capital=substr(address2,13,2);
Correct Answer : 1
The SCAN function is used to extract words from a character value when you know the order of the words, when their position varies, and when the words are marked by some delimiter. In this case, you don't need to specify delimiters, because the blank and the comma are default delimiters.
Syntax SCAN(string, count(,charlist (,modifiers) ) ) Required Arguments string : specifies a character constant, variable, or expression. count : is a nonzero numeric constant, variable, or expression that has an integer value that specifies the number of the word in the character string that you want SCAN to select. For example, a value of 1 indicates the first word, a value of 2 indicates the second word, and so on. The following rules apply: If count is positive, SCAN counts words from left to right in the character string. If count is negative, SCAN counts words from right to left in the character string.
Optional Arguments charlist : specifies an optional character expression that initializes a list of characters. This list determines which characters are used as the delimiters that separate words. The following rules apply: By default, all characters in charlist are used as delimiters. If you specify the K modifier in the modifier argument, then all characters that are not in charlist are used as delimiters.
Tip:You can add more characters to charlist by using other modifiers.
Question : The variable EmpCode contains values such as FL and MX. The fourth character identifies sex. How do you assign these character codes to a new variable named MaleORFemale? 1. MaleORFemale=scan(empcode,4); 2. MaleORFemale=scan(empcode,4,1); 3. MaleORFemale=substr(empcode,4); 4. MaleORFemale=substr(empcode,4,1);
Correct Answer : 4
The SUBSTR function is best used when you know the exact position of the substring to extract from the character value. You specify the position to start from and the number of characters to extract. Syntax : SUBSTR(variable, position(,length))=characters-to-replace
Required Arguments variable : specifies a character variable. position : specifies a numeric constant, variable, or expression that is the beginning character position. characters-to-replace : specifies a character constant, variable, or expression that will replace the contents of variable. Tip:Enclose a literal string of characters in quotation marks.
Optional Argument length : specifies a numeric constant, variable, or expression that is the length of the substring that will be replaced. Restriction:length cannot be larger than the length of the expression that remains in variable after position. Tip:If you omit length, SAS uses all of the characters on the right side of the assignment statement to replace the values of variable. Details : If you use an undeclared variable, it will be assigned a default length of 8 when the SUBSTR function is compiled. When you use the SUBSTR function on the left side of an assignment statement, SAS replaces the value of variable with the expression on the right side. SUBSTR replaces length characters starting at the character that you specify in position.
Example : The following SAS statements produce these results. SAS Statement a='KIDNAP'; substr(a,1,3)='CAT'; put a;
1. the data portion of every data set in the SASUSER library 2. the data portion of the data set SASUSER.AIRPLANES only 3. Access Mostly Uused Products by 50000+ Subscribers 4. the descriptor portion of the data set SASUSER.AIRPLANES only