SAS Base Functions Practice

Ace your homework & exams now with Quizwiz!

Name the function A. Floor B. Ceiling C. Round D. Integer E. Propcase F. Lowcase G. Upcase F. Random

A. Floor Syntax: floor(<argument>);

Name the function that returns the value 'rounded‐up' to the smallest integer larger than the argument. A. Floor B. Ceiling C. Round D. Integer E. Propcase F. Lowcase G. Upcase F. Random

B. Ceiling Syntax: ceil(<argument>);

Name the function that returns the value rounded to the unit specified. A. Floor B. Ceiling C. Round D. Integer E. Propcase F. Lowcase G. Upcase F. Random

C. Round Syntax: round(<argument>,<round-off-unit>);

Select the proper syntax to perform the following instructions: Specify the proper function that returns the value 'rounded‐up' to the smallest integer larger than the argument. A. floor(<argument>); B. round(<argument>,<round-off-unit>); C. ceil(<argument>); D. int(<argument>);

C. ceil(<argument>);

Select the proper syntax to perform the following instructions: Specify the proper function that removes multiple blanks from a character string by translating each occurrence of two or more consecutive blanks into a single blank. A. <var>=left(<string>); B. <var>=right(<string>); C. <var>=trim(<string>); D. <var>=compbl(<string>);

D. <var>=compbl(<string>);

Name the function used to specify a variable equaling the current day of the month listed as an integer. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

G. Day Syntax: DAY(<SASdate>) gives day of month (1 to 31) The <SASdate> above can be a variable, a numeric constant or a date constant.

Name the function that returns character values all in uppercase. A. Floor B. Ceiling C. Round D. Integer E. Propcase F. Lowcase G. Upcase F. Random

G. Upcase Syntax: <var=>upcase(<string>);

Assume today is Tuesday, November 24th. Months=INTCK('Month', '24NOV2020'd, '01JAN2021'd); What is months equal to?

Months= 2 Counts intervals beginning with first day of each month Dec. 01, Jan. 01

Assume today is Tuesday, November 24th. Weeks=INTCK('week', '24NOV2020'd, '28NOV2020'd); What is weeks equal to?

Weeks= 0 the 28th is 4 days after Tuesday wed, thurs, fri, sat weeks counts by the beginning of the week on Sunday to count week intervals. if 29th weeks=1

A typical value for the character variable Target is 123,456. Which statement correctly converts the values of Target to numeric values when creating the variable TargetNo? a. TargetNo=input(target,comma6.); b. TargetNo=input(target,comma7.); c. TargetNo=put(target,comma6.); d. TargetNo=put(target,comma7.);

A typical value for the character variable Target is 123,456. Which statement correctly converts the values of Target to numeric values when creating the variable TargetNo? a. TargetNo=input(target,comma6.); b. TargetNo=input(target,comma7.); c. TargetNo=put(target,comma6.); d. TargetNo=put(target,comma7.);

Select the proper syntax to perform the following instructions: Specify the proper function to specify a variable equaling the current day of the month listed as an integer. A. <var>=day(<SASdate>); B. <var>=qtr(<SASdate>); C. <var>=year(<SASdate>); D. <var>=wekday(<SASdate>); E. <var>=month(<SASdate>);

A. <var>=day(<SASdate>); DAY(<SASdate>) gives day of month (1 to 31) The <SASdate> above can be a variable, a numeric constant or a date constant.

Select the proper syntax to perform the following instructions: Specify the proper function used to search a character value for a specified string. A. <var>=index(<source>, <excerpt>); B. <var>=tranwrd(<source>, <target>, <replacement>); C. <var>=compress(<source> ,<characters>, '<modifier(s)>'); D. <var>=catx('<delimiter>', <string>, <string>);

A. <var>=index(<source>, <excerpt>); It searches from left to right, looking for the first occurrence of the string, and returns the position of the string's first character. If the string does not exist, it returns 0.

Select the proper syntax to perform the following instructions: Specify the proper function for finding the number of time intervals occurring in a given time span. A. <var>=intck('<interval>' , '<ddmmmyy>'d , 'ddmmmyy'd); B. <var>=intck('<interval>' , '<ddmmmyy>' , 'ddmmmyy'); C. <var>=intnx('<interval>', 'ddmmmyy'd, <increment>); D. <var>=intnx('<interval>', 'ddmmmyy', <increment>);

A. <var>=intck('<interval>' , '<ddmmmyy>'d , 'ddmmmyy'd); The type of INTERVAL (date, time, or datetime) must match the type of values used in (<interval>,<FROM>, <TO>) Example: <var>=intck('hours' , '5:00't , '6:00't); or <var>=intck('second','01jan2009:00:00:00'dt,'01jan2010:00:00:00'dt);

Select the proper syntax to perform the following instructions: Specify the proper function that produces trailing blanks. A. <var>=left(<string>); B. <var>=right(<string>); C. <var>=trim(<string>); D. <var>=compbl(<string>);

A. <var>=left(<string>); To remove those blanks the trim function can then be applied. Example: TRIM(LEFT(<var>)); NOTE: length of a TRIMMED Variable is the same as the untrimmed variable. Length is NOT trimmed. This is true for the left function as well.

Select the proper syntax to perform the following instructions: Specify the proper function that returns the value with 1st character upper case and the rest in lower cases. A. <var>=propcase(<string>); B. <var=>upcase(<string>); C. <var>=lowcase(<string>); D. <var>=allcaps(<string>);

A. <var>=propcase(<string>);

Select the proper syntax to perform the following instructions: Specify the proper function that extracts a character string from variables, specifically extracting the first word from the right. A. <var>=scan(<string>,-1); B. <var>=scan(<string>,1); C. <var>=substr(<string>,-1) D. <var>=substr(<string>,1)

A. <var>=scan(<string>,-1); If the count is positive, SCAN counts words from left to right in the character string. If the count is negative, SCAN counts words from right to left in the character string.

Select the proper syntax to perform the following instructions: Specify the proper function to specify a variable equaling the current time as a SAS time. A. <var>=time(); B. <var>=date(); C. <var>=datetime();

A. <var>=time(); time(); gives current time as a SAS time

Name the function that that extracts a character string from variables. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

A. Scan Syntax: where <cl> equals character list <var>=scan(<string>,<count>,<cl>,'<modifier>'); <string> specifies a character constant, variable, or expression. <count> is a nonzero numeric constant, variable, or expression that has an integer value. The integer value 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. Example: Name = 'CURTIS, BEN MIKE'; Fname2=scan(Name,2,', '); gives BEN Fname3=SCAN(name,3); gives the result MIKE Fname4=SCAN(Name,2,','); gives BEN MIKE

Name the function that calculates the date differences between two dates in years. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

A. Yrdif Syntax: <var>=yrdif(<Start_date>, <End_date>, <basis_n/m>); Example: <var>=yrdif(2,9,1976 , 8,19,2006, 30/360); or <var>=yrdif(2,9,1976 , 8,19,2006, ACT/ACT); ACT specifies actual calendar dates rather than generalizing to 30 day months / 360 day years.

Select the proper syntax to perform the following instructions: Specify the proper function that returns the value 'rounded‐down' to largest integer smaller than the argument; A. floor(<argument>); B. round(<argument>,<round-off-unit>); C. ceil(<argument>); D. int(<argument>);

A. floor(<argument>);

Select the proper syntax to perform the following instructions: Specify the proper function that replaces part of a character string. Where <cl>=character list. A. substrn(<string>, <position> , <length>)=<var>; B. <var>=substrn(<string>, <position> , <length>); C. <var>=scan(<string>,<count>,<cl>,'<modifier>'); D. <var>=catx('<delimiter>', <string>, <string>); E. <var>=find(<string>, <substring> , <start-position> , '<modifier(s)>');

A. substrn(<string>, <position> , <length>)=<var>; If <length> is omitted in the SUBSTR function in left-side SUBSTR then all remaining characters are replaced (from <position> to the end of the string) NOTE: The length of the result in either right or left side SUBSTR has the same length as the string. Hence, it is important to specify a LENGTH statement as needed prior to the use of the SUBSTR function. Example: NAME = 'CURTIS, BEN MIKE'; Substr(name,1,6)='LEE';

Select the proper syntax to perform the following instructions: Specify the proper function that returns character values all in uppercase. A. <var>=propcase(<string>); B. <var=>upcase(<string>); C. <var>=lowcase(<string>); D. <var>=rand('normal');

B. <var=>upcase(<string>);

Select the proper syntax to perform the following instructions: Specify the proper function that calculates the date differences between two dates in days. A. <var>=datdif(<Start_date>, <End_date>, <basis_n/m>); B. <var>=datdif('<Start_date>', '<End_date>'); C. <var>=yrdif('<Start_date>', '<End_date>'); D. <var>=yrdif(<Start_date>, <End_date>, <basis_n/m>);

B. <var>=datdif(<Start_date>, <End_date>, <basis_n/m>); Example: <var>=datdif(2,9,1976 , 8,19,2006, 30/360); or <var>=datdif(2,9,1976 , 8,19,2006, ACT/ACT); ACT specifies actual calendar dates rather than generalizing to 30 day months / 360 day years.

Select the proper syntax to perform the following instructions: Specify the proper function to specify a variable equaling the current quarter of the year listed as an integer. A. <var>=day(<SASdate>); B. <var>=qtr(<SASdate>); C. <var>=year(<SASdate>); D. <var>=wekday(<SASdate>); E. <var>=month(<SASdate>);

B. <var>=qtr(<SASdate>); QTR(<SASdate>) gives quarter in the year of the date (1 to 4)

Select the proper syntax to perform the following instructions: Specify the proper function that extracts a character string from variables, specifically extracting the first word from the left. A. <var>=scan(<string>,-1); B. <var>=scan(<string>,1); C. <var>=substr(<string>,-1) D. <var>=substr(<string>,1)

B. <var>=scan(<string>,1); If the count is positive, SCAN counts words from left to right in the character string. If the count is negative, SCAN counts words from right to left in the character string.

Select the proper syntax to perform the following instructions: Specify the proper function that extracts a part of a character starting at a specified position. Where <cl>=character list. A. substrn(<string>, <position> , <length>)=<var>; B. <var>=substrn(<string>, <position> , <length>); C. <var>=scan(<string>,<count>,<cl>,'<modifier>'); D. <var>=catx('<delimiter>', <string>, <string>); E. <var>=find(<string>, <substring> , <start-position> , '<modifier(s)>');

B. <var>=substrn(<string>, <position> , <length>); If <length> is omitted in the SUBSTR function in right-side SUBSTR then all remaining characters are extracted (from <length> to the end of the string) NOTE: The length of the result in either right or left side SUBSTR has the same length as the string. Hence, it is important to specify a LENGTH statement as needed prior to the use of the SUBSTR function. Example: NAME = 'CURTIS, BEN MIKE'; MidName=SCAN(name,3); Midinit = SUBSTR(MidName,1, 1); Midinit2=SUBSTR(SCAN(Name,3),1,1); [Ex:NESTED]

Select the proper syntax to perform the following instructions: Specify the proper function to specify a variable equaling today's date as a SAS date, just the date. A. <var>=time(); B. <var>=date(); C. <var>=datetime();

B. <var>=today(); today(); gives today's date value as a SAS date or date(); gives today's date value as a SAS date

Select the proper syntax to perform the following instructions: Specify the proper function that replaces or removes all occurrences of a string of characters from within a character string. A. <var>=index(<source>, <excerpt>); B. <var>=tranwrd(<source>, <target>, <replacement>); C. <var>=compress(<source> ,<characters>, '<modifier(s)>'); D. <var>=catx('<delimiter>', <string>, <string>);

B. <var>=tranwrd(<source>, <target>, <replacement>); <source> is the source string to be translated or updated. <target> is the string SAS is looking for in the source that is to be removed or replaced. <replacement> specifies the new string to replace the target. Use quotations if targeting a character string or replacing with a string of characters. To remove the <target> from <source>, simply use an empty quotation '' for <replacement>. The default length of the result from TRANWRD is 200. NOTE: TRANWRD function is case sensitive. Use UPCASE() , LOWCASE() function as needed.

Name the function that applies multiples of a given interval to a date, time, or datetime value and returns the resulting SAS value. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

B. Datdif Syntax: <var>=datdif(<Start_date>, <End_date>, <basis_n/m>); Example: <var>=datdif(2,9,1976 , 8,19,2006, 30/360); or <var>=datdif(2,9,1976 , 8,19,2006, ACT/ACT); ACT specifies actual calendar dates rather than generalizing to 30 day months / 360 day years.

Select the proper syntax to perform the following instructions: Specify the proper syntax for the MDY function to create a SAS value detailing how many days since Jan/01/1960. A. MDY(20,15,15); B. MDY(10,15,15); C. MDY(10,35,15); D. MDY(10/15/15);

B. MDY(Mon, Day, Year) (only valid option as M has max=12 D max=31) NOTE: if you use a two-digit year, the default year‐cutoff is applied (1920) unless you previously submitted an options yearcutoff= with a year different than 1920. Ex: Assuming 1920 is the cutoff year(default), MDY(11,1,15); results in the number of days November 1, 2015 is from January 1, 1960. MDY (11,1,1915); results in the number of days November 1, 1915 is from January 1, 1960. MDY(11,1,23); results in number of days November 1, 1923 is from Janbuary 1, 1960. MDY(14,10, 2010) returns missing as 14 isn't a month 1‐12.

Name the function that that replaces part of a character string. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

B. Substring Left Syntax: substrn(<string>, <position> , <length>)=<var>; If <length> is omitted in the SUBSTR function in left-side SUBSTR then all remaining characters are replaced (from <position> to the end of the string) NOTE: The length of the result in either right or left side SUBSTR has the same length as the string. Hence, it is important to specify a LENGTH statement as needed prior to the use of the SUBSTR function. Example: NAME = 'CURTIS, BEN MIKE'; Substr(name,1,6)='LEE';

Select the proper syntax to perform the following instructions: Specify the proper function that returns the value rounded to the unit specified. A. floor(<argument>); B. round(<argument>,<round-off-unit>); C. ceil(<argument>); D. int(<argument>);

B. round(<argument>,<round-off-unit>);

Select the proper syntax to perform the following instructions: Specify the proper function that returns a character string with specified characters removed from the original string. A. <var>=index(<source>, <excerpt>); B. <var>=tranwrd(<source>, <target>, <replacement>); C. <var>=compress(<source> ,<characters>, '<modifier(s)>'); D. <var>=catx('<delimiter>', <string>, <string>);

C. <var>=compress(<source> ,<characters>, '<modifier(s)>'); Null arguments are treated as a string with a length of zero. <characters> specifies a character constant, variable, or expression. NOTE: If specifying a string of actual characters for <characters> use quotations.

Select the proper syntax to perform the following instructions: Specify the proper function to specify a variable equaling today's date and time as a SAS datetime. A. <var>=time(); B. <var>=date(); C. <var>=datetime();

C. <var>=datetime(); datetime(); gives current date time as a SAS datetime

Select the proper syntax to perform the following instructions: Specify the proper function that applies multiples of a given interval to a date, time, or datetime value and returns the resulting SAS value. A. <var>=intck('<interval>' , '<ddmmmyy>'d , 'ddmmmyy'd); B. <var>=intck('<interval>' , '<ddmmmyy>' , 'ddmmmyy'); C. <var>=intnx('<interval>', 'ddmmmyy'd, <increment>); D. <var>=intnx('<interval>', 'ddmmmyy', <increment>);

C. <var>=intnx('<interval>', 'ddmmmyy'd, <increment>); The type of INTERVAL (date, time, or datetime) must match the type of values used in (<interval>,<FROM>, <increment>) Example: <var>=intnx('minute', '01FEB2010:00:00:00'dt, 1); or <var>=intnx('month', '05FEB2010'd, 1, 'm'); NOTE: Alignment- forces the alignment of the returned date to be the beginning <'b'>, middle <'m'>, end <'e'>, or same day <'s'> of the time interval. The default is the beginning.

Select the proper syntax to perform the following instructions: Specify the proper function that returns character values all in lowercase. A. <var>=propcase(<string>); B. <var=>upcase(<string>); C. <var>=lowcase(<string>); D. <var>=allcaps(<string>);

C. <var>=lowcase(<string>);

Select the proper syntax to perform the following instructions: Specify the proper function that extracts a character string from variables. Where <cl>=character list. A. substrn(<string>, <position> , <length>)=<var>; B. <var>=substrn(<string>, <position> , <length>); C. <var>=scan(<string>,<count>,<cl>,'<modifier>'); D. <var>=catx('<delimiter>', <string>, <string>); E. <var>=find(<string>, <substring> , <start-position> , '<modifier(s)>');

C. <var>=scan(<string>,<count>,<cl>,'<modifier>'); <string> specifies a character constant, variable, or expression. <count> is a nonzero numeric constant, variable, or expression that has an integer value. The integer value 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. Example: Name = 'CURTIS, BEN MIKE'; Fname2=scan(Name,2,', '); gives BEN Fname3=SCAN(name,3); gives the result MIKE Fname4=SCAN(Name,2,','); gives BEN MIKE

Select the proper syntax to perform the following instructions: Specify the proper function that trims trailing blanks. A. <var>=left(<string>); B. <var>=right(<string>); C. <var>=trim(<string>); D. <var>=compbl(<string>);

C. <var>=trim(<string>); Trailing blanks are often a result of applying SAS character functions and can cause problems when concatenating strings. NOTE: length of a TRIMMED Variable is the same as the untrimmed variable. Length is NOT trimmed. This is true for the left function as well.

Select the proper syntax to perform the following instructions: Specify the proper function to specify a variable equaling the current year listed as an integer. A. <var>=day(<SASdate>); B. <var>=qtr(<SASdate>); C. <var>=year(<SASdate>); D. <var>=wekday(<SASdate>); E. <var>=month(<SASdate>);

C. <var>=year(<SASdate>); YEAR(<SASdate>) gives the year of the date (4 digit year) The <SASdate> above can be a variable, a numeric constant or a date constant.

Select the proper syntax to perform the following instructions: Specify the proper procedure to produce a nested function; A. Data <libref>.<filename>; set <libref>.<filename>; <var>=<function>(); run; B. Data <libref>.<filename>; set <libref>.<filename>; <var>=<function>(<function>); run; C. Data <libref>.<filename>; set <libref>.<filename>; <var>=<function>(<function>()); run; D. Data <libref>.<filename>; set <libref>.<filename>; <var>=<function><function>(); run;

C. Data <libref>.<filename>; set <libref>.<filename>; <var>=<function>(<function>()); run; Example: Data Nest_Ex; name = 'Curtis, Ben, mike'; Midname=trim(UPCASE(substr(scan(name,3),1,1)))||'.'; Run;

Name the function that applies multiples of a given interval to a date, time, or datetime value and returns the resulting SAS value. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

C. Intnx Syntax: <var>=intnx('<interval>', 'ddmmmyy'd, <increment>); The type of INTERVAL (date, time, or datetime) must match the type of values used in (<interval>,<FROM>, <increment>) Example: <var>=intnx('minute', '01FEB2010:00:00:00'dt, 1); or <var>=intnx('month', '05FEB2010'd, 1, 'm'); NOTE: Alignment- forces the alignment of the returned date to be the beginning <'b'>, middle <'m'>, end <'e'>, or same day <'s'> of the time interval. The default is the beginning.

Name the function that extracts a part of a character starting at a specified position. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

C. Substring Right Syntax: <var>=substrn(<string>, <position> , <length>); If <length> is omitted in the SUBSTR function in right-side SUBSTR then all remaining characters are extracted (from <length> to the end of the string) NOTE: The length of the result in either right or left side SUBSTR has the same length as the string. Hence, it is important to specify a LENGTH statement as needed prior to the use of the SUBSTR function. Example: NAME = 'CURTIS, BEN MIKE'; MidName=SCAN(name,3); Midinit = SUBSTR(MidName,1, 1); Midinit2=SUBSTR(SCAN(Name,3),1,1); [Ex:NESTED]

Select the proper syntax to perform the following instructions: Specify the proper function that concatenates character strings, trims leading blanks, and left justifies. A. <var>=index(<source>, <excerpt>); B. <var>=tranwrd(<source>, <target>, <replacement>); C. <var>=compress(<source> ,<characters>, '<modifier(s)>'); D. <var>=catx('<delimiter>', <string>, <string>);

D. <var>=catx('<delimiter>', <string>, <string>); '<delimiter>' specifies the character string used for separating strings that will be concatenated. It must be in a quotation mark. The default length for an assignment using the CATX is 200. Example: Address = CATX(', ', CITY, STATE, ZIPCODE);

Select the proper syntax to perform the following instructions: Specify the proper function that concatenates character strings, trims leading blanks, and left justifies. Where <cl>=character list. A. substrn(<string>, <position> , <length>)=<var>; B. <var>=substrn(<string>, <position> , <length>); C. <var>=scan(<string>,<count>,<cl>,'<modifier>'); D. <var>=catx('<delimiter>', <string>, <string>); E. <var>=find(<string>, <substring> , <start-position> , '<modifier(s)>');

D. <var>=catx('<delimiter>', <string>, <string>); '<delimiter>' specifies the character string used for separating strings that will be concatenated. It must be in a quotation mark. The default length for an assignment using the CATX is 200. Example: Address = CATX(', ', CITY, STATE, ZIPCODE);

Select the proper syntax to perform the following instructions: Specify the proper function that returns a random number in a normal manner. A. <var>=propcase(<string>); B. <var=>upcase(<string>); C. <var>=lowcase(<string>); D. <var>=rand('normal');

D. <var>=rand('normal'); Example: data randomtest; *A random number selected uniformly from 0 to 1.; randnum=rand('uniform'); *A random number selected uniformly from -5 to 5; randnum2=-5+10*rand('uniform'); *A random number selected from the normal distribution with mean 5 and variance 3; randnum3=rand('normal',5,3); run; uniform and normal use algorithmic formulas, not ranges to chose a number within.

Select the proper syntax to perform the following instructions: Specify the proper function to specify a variable equaling the current weekday of the week listed as an integer. A. <var>=day(<SASdate>); B. <var>=qtr(<SASdate>); C. <var>=year(<SASdate>); D. <var>=wekday(<SASdate>); E. <var>=month(<SASdate>);

D. <var>=wekday(<SASdate>); WEEKDAY(<SASdate>) gives the day of week (1 to 7; 1 is Sunday, and so on) The <SASdate> above can be a variable, a numeric constant or a date constant.

Select the proper syntax to perform the following instructions: Specify the proper function that calculates the date differences between two dates in years. A. <var>=datdif(<Start_date>, <End_date>, <basis_n/m>); B. <var>=datdif('<Start_date>', '<End_date>'); C. <var>=yrdif('<Start_date>', '<End_date>'); D. <var>=yrdif(<Start_date>, <End_date>, <basis_n/m>);

D. <var>=yrdif(<Start_date>, <End_date>, <basis_n/m>); Example: <var>=yrdif(2,9,1976 , 8,19,2006, 30/360); or <var>=yrdif(2,9,1976 , 8,19,2006, ACT/ACT); ACT specifies actual calendar dates rather than generalizing to 30 day months / 360 day years.

Name the function that removes multiple blanks from a character string by translating each occurrence of two or more consecutive blanks into a single blank. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

D. Compbl Syntax: <var>=compbl(<string>);

Name the function for finding the number of time intervals occurring in a given time span. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

D. Intck Syntax: <var>=intck('<interval>' , '<ddmmmyy>'d , 'ddmmmyy'd); The type of INTERVAL (date, time, or datetime) must match the type of values used in (<interval>,<FROM>, <TO>) Example: <var>=intck('hours' , '5:00't , '6:00't); or <var>=intck('second','01jan2009:00:00:00'dt,'01jan2010:00:00:00'dt);

Name the function that returns the integer part of the argument. A. Floor B. Ceiling C. Round D. Integer E. Propcase F. Lowcase G. Upcase F. Random

D. Integer Syntax: int(<argument>);

Select the proper syntax to perform the following instructions: Specify the proper function that returns the integer part of the argument. A. floor(<argument>); B. round(<argument>,<round-off-unit>); C. ceil(<argument>); D. int(<argument>);

D. int(<argument>);

Select the proper syntax to perform the following instructions: Specify the proper function that searches for a specific substring within a character value and returns the substring's starting position. Where <cl>=character list. A. substrn(<string>, <position> , <length>)=<var>; B. <var>=substrn(<string>, <position> , <length>); C. <var>=scan(<string>,<count>,<cl>,'<modifier>'); D. <var>=catx('<delimiter>', <string>, <string>); E. <var>=find(<string>, <substring> , <start-position> , '<modifier(s)>');

E. <var>=find(<string>, <substring> , <start-position> , '<modifier(s)>'); <string> specifies a character constant, variable or expression that will be searched for substrings. <substring> is a character constant, variable or expression that is enclosed in quotation marks to be searched for in the string. <startposition> is an integer that specifies the position at which the search should start and the direction of the search, deafualt forward (left to right). If <startpostion> is negative is searches backward starting at the integer. If <startposition> is not given, FIND searches from left to right starting from 1st position.

Select the proper syntax to perform the following instructions: Specify the proper function to specify a variable equaling the current month of the year listed as an integer. A. <var>=day(<SASdate>); B. <var>=qtr(<SASdate>); C. <var>=year(<SASdate>); D. <var>=wekday(<SASdate>); E. <var>=month(<SASdate>);

E. <var>=month(<SASdate>); MONTH(<SASdate>) gives the month of the date (1 to 12) The <SASdate> above can be a variable, a numeric constant or a date constant.

Name the function that returns a character string with specified characters removed from the original string. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

E. Compress Syntax: <var>=compress(<source> ,<characters>, '<modifier(s)>'); Null arguments are treated as a string with a length of zero. <characters> specifies a character constant, variable, or expression. NOTE: If specifying a string of actual characters for <characters> use quotations.

Name the function that returns the value with 1st character upper case and the rest in lower cases. A. Floor B. Ceiling C. Round D. Integer E. Propcase F. Lowcase G. Upcase F. Random

E. Propcase Syntax: <var>=propcase(<string>);

Name the function used to specify a variable equaling the current year listed as an integer. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

E. Year Syntax: YEAR(<SASdate>) gives the year of the date (4 digit year) The <SASdate> above can be a variable, a numeric constant or a date constant.

Name the function used to search a character value for a specified string. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

F. Index Syntax: <var>=index(<source>, <excerpt>); It searches from left to right, looking for the first occurrence of the string, and returns the position of the string's first character. If the string does not exist, it returns 0.

Name the function that returns character values all in lowercase. A. Floor B. Ceiling C. Round D. Integer E. Propcase F. Lowcase G. Upcase F. Random

F. Lowcase Syntax: <var>=lowcase(<string>);

Name the function that returns a random number. A. Floor B. Ceiling C. Round D. Integer E. Propcase F. Lowcase G. Upcase F. Random

F. Random Syntax: <var>=rand('normal'); Example: data randomtest; *A random number selected uniformly from 0 to 1.; randnum=rand('uniform'); *A random number selected uniformly from -5 to 5; randnum2=-5+10*rand('uniform'); *A random number selected from the normal distribution with mean 5 and variance 3; randnum3=rand('normal',5,3); run; uniform and normal use algorithmic formulas, not ranges to chose a number within.

Name the function used to specify a variable equaling the current weekday of the week listed as an integer. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

F. Weekday Syntax: WEEKDAY(<SASdate>) gives the day of week (1 to 7) 1 is Sunday, and so on The <SASdate> above can be a variable, a numeric constant or a date constant.

Name the function that searches for a specific substring within a character value and returns the substring's starting position. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

G. Find Syntax: <var>=find(<string>, <substring> , <start-position> , '<modifier(s)>'); <string> specifies a character constant, variable or expression that will be searched for substrings. <substring> is a character constant, variable or expression that is enclosed in quotation marks to be searched for in the string. <startposition> is an integer that specifies the position at which the search should start and the direction of the search, deafualt forward (left to right). If <startpostion> is negative is searches backward starting at the integer. If <startposition> is not given, FIND searches from left to right starting from 1st position.

Name the function that produces trailing blanks. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

H. Left Syntax: <var>=left(<string>); To remove those blanks the trim function can then be applied. Example: TRIM(LEFT(<var>)); NOTE: length of a TRIMMED Variable is the same as the untrimmed variable. Length is NOT trimmed. This is true for the left function as well.

Name the function used to specify a variable equaling the current month of the year listed as an integer. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

H. Month Syntax: <var>=month(<SASdate>); gives the month of the date (1 to 12) The <SASdate> above can be a variable, a numeric constant or a date constant.

Name the function used to specify a variable equaling the current quarter of the year listed as an integer. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

I. Quarter Syntax: <var>=qtr(<SASdate>); gives the quarter of the date (1 to 4)

Name the function that replaces or removes all occurrences of a string of characters from within a character string. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

I. Tranwrd Syntax: <var>=tranwrd(<source>, <target>, <replacement>); <source> is the source string to be translated or updated. <target> is the string SAS is looking for in the source that is to be removed or replaced. <replacement> specifies the new string to replace the target. Use quotations if targeting a character string or replacing with a string of characters. To remove the <target> from <source>, simply use an empty quotation '' for <replacement>. The default length of the result from TRANWRD is 200. NOTE: TRANWRD function is case sensitive. Use UPCASE() , LOWCASE() function as needed.

Name the function used to specify a variable equaling the current time as a SAS time. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

J. Time Syntax: <var>=time();

Name the function that trims trailing blanks. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

J. Trim Syntax: <var>=trim(<string>); Trailing blanks are often a result of applying SAS character functions and can cause problems when concatenating strings. NOTE: length of a TRIMMED Variable is the same as the untrimmed variable. Length is NOT trimmed. This is true for the left function as well.

Name the function that concatenates character strings, trims leading blanks, and left justifies. A. Scan B. Substring Left C. Substring Right D. Compbl E. Compress F. Index G. Find H. Left I. Tranwrd J. Trim K. Catx

K. Catx Syntax: <var>=catx('<delimiter>', <string>, <string>); '<delimiter>' specifies the character string used for separating strings that will be concatenated. It must be in a quotation mark. The default length for an assignment using the CATX is 200. Example: Address = CATX(', ', CITY, STATE, ZIPCODE);

Name the function used to specify a variable equaling today's date and time as a SAS datetime. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Day G. Week H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

K. Datetime Syntax: <var>=datetime();

Name the function used to specify a variable equaling today's date as a SAS date, just the date. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

L. Today Syntax: <var>=today();

Name the function that creates a SAS value detailing how many days since Jan/01/1960. A. Yrdif B. Datdif C. Intnx D. Intck E. Year F. Weekday G. Day H. Month I. Quarter J. Time K. Datetime L. Today M. MDY

M. MDY Syntax: MDY(Mon, Day, Year)

Assume today is Tuesday, November 24th. Years=INTCK('Year', '24NOV2020'd, '03JAN2023'd); What is years equal to?

Years= 3 Counts interval of years. No beginning, middle, or end needed to be known when doing a whole year as opposed to 'month' or 'week'. Might need to know date intervals if 'semiyear' is specified instead of year for example.

You wish to create a variable FullName by concatenating last names and first names which you will extract from the variable Name. Name is in the retail.maillist data set and has values in the form lastname,firstname middlename. The length of Name is 50. What is the length of the program: data work.maillist; set retail.maillist; length FullName $ 40; firstname = scan(name,2); lastname = scan(name,1); fullname=trim(firstname)||' '||trim(lastname); run; a. 40 b. 200 c. 201 d. 401

a. 40 length statement preceded first instance of full name, so full name is assigned a length of 40

When applying the following SAS function, what is the correct value from the function? FLOOR(-12.345) = a. -12 b. -13 c. -12.3 d. 12

b. -13 because floor returns the value rounded‐down to largest integer smaller than the argument. Since negative 12.345 it would be rounded down to -13

You wish to create a variable FullName by concatenating last names and first names which you will extract from the variable Name. Name is in the retail.maillist data set and has values in the form lastname,firstname middlename. The length of Name is 50. What is the length of the program: data work.maillist; Length name $ 100; set retail.maillist; firstname = scan(name,2); lastname = scan(name,1); fullname=firstname||' '||lastname; run; a. 40 b. 200 c. 201 d. 101

b. 200

You wish to create a variable FullName by concatenating last names and first names which you will extract from the variable Name. Name is in the retail.maillist data set and has values in the form lastname,firstname middlename. The length of Name is 50. What is the length of the program: data work.maillist; set retail.maillist; firstname = scan(name,2); lastname = scan(name,1); fullname= catx (' ', firstname, lastname); run; a. 40 b. 200 c. 201 d. 10

b. 200 catx and tranwrd hava a default length of 200

Within the data set Furniture.Bookcase, the variable Finish contains values such as ash/cherry/teak/matte-black. Which of the following creates a subset of the data in which the values of Finish contain the string walnut? Make the search for the string case-insensitive. a. data work.bookcase; set furnitur.bookcase; if index(finish,walnut) = 0; run; b. data work.bookcase; set furnitur.bookcase; if index(UPCASE(finish),'WALNUT') > 0; run; c. data work.bookcase; set furnitur.bookcase; If index(finish,'walnut') > 0; run; d. data work.bookcase; set furnitur.bookcase; if index(lowcase(finish),walnut) = 0; run;

b. data work.bookcase; set furnitur.bookcase; if index(UPCASE(finish),'WALNUT') > 0; run; > 0 because if string does not exist it returns a zero. anything above will be WALNUT. Can also use the I modifier in the FIND function to make the search ignore case, you must enclose it in quotation marks. Example: if index(UPCASE(finish),'WALNUT','i') > 0; run;

A university has phone numbers with exchanges 565 and 765. It wishes to change all phone numbers with the 565 exchange to 765. The data set Mylib.university includes the variable Phone, which contains telephone numbers in the form 565-1234 or 765-4321. Which of the following programs correctly changes the values of Phone? a. data work.university (drop=Exchange); set Mylib.university; Exchange=substr(Phone,1,3); if Exchange='565' then scan(Phone,1,3)='765';run; b. data work.university (drop=Exchange); set Mylib.university; Exchange=substr(Phone,1,3); if Exchange='565' then substr(Phone,1,3)='765';run; c. data work.university (drop=Exchange); set Mylib.university; Exchange=substr(Phone,1,3); if Exchange='565' then phone=scan('765',1,3);run; d. data work.university (drop=Exchange); set Mylib.university; Exchange=substr(Phone,1,3); if Exchange='565' then phone=substr('765',1,3);run;

b. data work.university (drop=Exchange); set Mylib.university; Exchange=substr(Phone,1,3); if Exchange='565' then substr(Phone,1,3)='765';run; not a. or c. we scan extracts does not replace also c. uses scan incorrectly using '765' instead of the string not d. as uses substr incorrectly. substr('765',1,3) is improper syntax as you state the first character to begin with then how many characters to read as in b.

When applying the following SAS function, what is the correct value from the function? ROUND(-456.78 , .1) = a. -457 b. -456.7 c. -456.8 d. -456

c. -456.8 Round(<integer>, .1) indicates to round to the nearest first decimal

You wish to create a variable FullName by concatenating last names and first names which you will extract from the variable Name. Name is in the retail.maillist data set and has values in the form lastname,firstname middlename. The length of Name is 50. What is the length of the program: data work.maillist; set retail.maillist; Length name $ 100; firstname = scan(name,2); lastname = scan(name,1); fullname=firstname||' '||lastname; run; a. 40 b. 200 c. 201 d. 101

c. 201 length statement precedes both instances of name and assigns a length of 100 to each. scan does not change length firstname 100 is concatenated with a space ||' '|| to lastname 100 so total 201

Assume the data set year_1 is created and exists in your work library. The following SAS program is submitted: Data revenue; Set year_1; Var1=mdy(1,15,1960); run; Which one the following values does the variable named VAR1 contain? a. A character string with the value '01/15/1960' b. A character string with the value '01Jan1960' c. A numeric value of 14 d. A numeric value of 15 e. A missing value of '.'

c. A numeric value of 14 mdy counts days since january 1st 1960 starting with 1. january 1st 1960 in this instance would be equal to zero. so 15th would give an SAS value of 14

What is the new value of Code? Code="HNL:96701-006"; Code=substr(Code,1,length(Code)-4); a. 96701-006 b. HNL: c. HNL:96701 d. 1-006

c. HNL:96701 When functions are nested, the innermost function executes first and passes its result to an outer function. The LENGTH function returns the length of the string (13) to the SUBSTR function. The SUBSTR function extracts a nine-character string (13-4) starting from position 1.

Suppose the YEARCUTOFF= system option is set to 1920. Which MDY function creates the date value for January 3, 2020? a. MDY(1,3,20) b. MDY(3,1,20) c. MDY(1,3,2020) d. MDY(3,1,2020)

c. MDY(1,3,2020) 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.

Due to growth within the 919 area code, the telephone exchange 555 is being reassigned to the 920 area code. The data set Clients.Piedmont includes the variable Phone, which contains telephone numbers in the form 919-555-1234. Which of the following programs will correctly change the values of Phone? a. data work.piedmont; set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); If substr(phone,1,3) ='919' and substr(phone,5,3) ='555' then scan(phone,1,3)='920'; run; b. data work.piedmont; set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); If substr(phone,1,3) ='919' and substr(phone,5,3) ='555' then phone=scan('920',1,3); run; c. data work.piedmont; set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); If substr(phone,1,3)='919' and substr(phone,5,3) ='555' then substr(phone,1,3)='920'; run; d. data work.piedmont; set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); If substr(phone,1,3) ='919' and substr(phone,5,3) ='555' then phone=substr('920',1,3); run;

c. data work.piedmont; set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); If substr(phone,1,3)='919' and substr(phone,5,3) ='555' then substr(phone,1,3)='920'; run; When the SUBSTR function is used on the left side of an assignment statement, it replaces characters at a specified position.

The variable Address2 contains values such as Piscataway, NJ and Las Vegas, NV How do you assign the two-letter state abbreviations to a new variable named State using comma as the delimiter. a. state=substr(city,2,','); b. state=scan(city,2,' '); c. state=scan(city,2,','); d. state=scan(city,2); e. state=substr(city2,13,2);

c. state=scan(city,2,','); extracts the second word of variable city and separates words intervals with the delimiter ',' not a. or c. substr starts looking at the character specified and reads to the interval specified. each has improper syntax and would cause errors. Would also not be useful as City names are different character lengths. not b. or d. b. uses space instead of a comma to delimit and d. uses incorrect syntax and would cause errors.

Make var2 true in the single observation of the SASfuctions data set by filling in the blanks below with the proper SAS function. if <answer-here>(' ','Math 610','SAS','Programming')='Math 610 SAS Programming' then var2='true'; else var2='false';

catx catx concatenates strings, remove leading, trailing blanks and insert separators Syntax: CATX(' '<separator>' <string1> '<separator>' <string2> '<separator>' <string3>'); (this one looks confusing as you have to know the total string is in quotes, which is why the first separator has three quotation marks among it, which is why there is also one at the end.

Make var1 true in the single observation of the SASfuctions data set by filling in the blanks below with the proper SAS function. < > < > is indicating multiple spaces. Ignore < and > for the code. length var1 var2 var3 var4 $5; if <answer-here>('MATH< >< >< >< >610 SAS Programming')='MATH 610 SAS Programming' then var1='true'; else var1='false';

compbl The COMBL function removes multiple blanks from a character string by translating each occurrence of two or more consecutive blanks into a single blank.

Make var4 true in the single observation of the SASfuctions data set by filling in the blanks below with the proper SAS function. if <answer-here>('MATH 610 SAS Programming+','+')='MATH 610 SAS Programming' then var4='true'; else var4='false';run;

compress compress returns a character string with specified characters removed from the original string. Null arguments are treated as a string with a length of zero. Syntax: COMPRESS(<source>, '<characters>>', '<modifiers(s)>');

Which statement replaces <statement-here> below to create the macro variable Location that is given the value London? Location is then referenced in the program below the statement. <statement-here> title "Airline Crew From &city"; proc print data=mylib.crew;where propcase(location)="&city"; run; a. &let city = London; b. let &city = London; c. %let city = "London"; d. %let city = London; e. let %city = London;

d. %let city = London; %let <macro> = <value>; is proper syntax quotes are not used around <value> &<macro> is syntax for using macro once created

You wish to create a variable FullName by concatenating last names and first names which you will extract from the variable Name. Name is in the retail.maillist data set and has values in the form lastname,firstname middlename. The length of Name is 50. What is the length of the program: data work.maillist; set retail.maillist; firstname = scan(name,2); lastname = scan(name,1); fullname=trim(firstname||' '||lastname); length FullName $ 40; run; a. 40 b. 200 c. 201 d. 101

d. 101 Length statement does not precede first instance of last name so does not assign a length of 40. scan and trim do not change length. 101 because firstname and lastname are concatenated with a space ||' '||

You wish to create a variable FullName by concatenating last names and first names which you will extract from the variable Name. Name is in the retail.maillist data set and has values in the form lastname,firstname middlename. The length of Name is 50. What is the length of the program: data work.maillist; set retail.maillist; firstname = scan(name,2); lastname = scan(name,1); fullname=firstname||' '||lastname; run; a. 40 b. 200 c. 201 d. 101

d. 101 scan extracts character string from character strings using delimiters. does not change length 101 as there firstname and lastname are concatenated with a space ||' '||

You wish to create a variable FullName by concatenating last names and first names which you will extract from the variable Name. Name is in the retail.maillist data set and has values in the form lastname,firstname middlename. The length of Name is 50. What is the length of the program: data work.maillist; set retail.maillist; firstname = trim(scan(name,2)); lastname = trim(scan(name,1)); fullname=trim(firstname)||' '||lastname; run; a. 40 b. 200 c. 201 d. 101

d. 101 trim does not change actual length, just trims leading blanks for output display scan does not change length either 101 as concatenated with space ||' '||

A typical value for the numeric variable SiteNum is 12.3. Which statement correctly converts the values of SiteNum to character values when creating the variable Location? a. Location=dept||'/'||input(sitenum,3.1); b. Location=dept||'/'||input(sitenum,4.1); c. Location=dept||'/'||put(sitenum,3.1); d. Location=dept||'/'||put(sitenum,4.1);

d. Location=dept||'/'||put(sitenum,4.1); You explicitly convert numeric values to character values by using the PUT function. Be sure 80 to select a format that can read the form of the values.

The variable IDCode contains values such as 12FA and 32MB. The third character identifies gender. How do you assign this character to a new variable named gender? a. gender=scan(idcode,3); b. gender=scan(idcode,3,1); c. gender=substr(idcode,3); d. gender=substr(idcode,3,1);

d. gender=substr(idcode,3,1); The SUBSTR function is best used when you know the exact position of the substring to extract from the character value. You specify the variable, the starting position, and the number of characters to extract.

Which function calculates the average of the variables Var1, Var2, Var3, and Var4? a. mean(var1,var4) b. mean(var1-var4) c. mean(of var1,var4) d. mean(of var1-var4)

d. mean(of var1-var4) Use a variable list to specify a range of variables as the function argument. When specifying a variable list, be sure to precede the list with the word OF. If you omit the word OF, the function argument might not be interpreted as expected. Example: b. calculates the mean of var1 minus var4.

Make var3 true in the single observation of the SASfuctions data set by filling in the blanks below with the proper SAS function. if <answer-here>('MATH 610 SASProgramming','prog','i')=14 then var3='true'; else var3='false';

find find searches for a specific substring within a character value and returns the substring's starting position. It does this in a way specified by modifiers and a starting position. FIND(<string>, '<substring>', '<modifiers>', <startpos>); no <startpos> is identified in the code before. 'i' modifier states to ignore the case of characters therefore it scans the entire string and displays the starting value of the substring 'prog' which is 14. (remember to include quotations of the string for the beginning position.)


Related study sets

Chapter 9: Teaching & Counseling PrepU

View Set

NES Elementary Subtest II 2 Math Only (NO GEOMETRY)

View Set

Vocab Level F Mastery Test Units 13-15

View Set

Ch. 15 Writing Job application-materials

View Set