Question : The following SAS program is submitted: footnote1 `Sales Report for Last Month'; footnote2 `Selected Products Only'; footnote3 `All Regions'; footnote4 `All Figures in Thousands of Dollars'; proc print data = sasuser.shoes; footnote2 `All Products'; run; Which footnote(s) is/are displayed in the report? 1. All Products 2. Sales Report for Last Month All Products 3. All Products All Regions All Figures in Thousands of Dollars 4. Sales Report for Last Month All Products All Regions All Figures in Thousands of Dollars
Correct Answer : 2 footnote 2 (the second one ) will over write the footnote2 and delete the rest of the footnotes 3 and 4 which are higher. The second footnote2 statement overrides the previous footnote2 and purges footnote3 and footnote4. Adding descriptive titles and footnotes is one of the easiest and most effective ways to improve the appearance of a report. You can use the TITLE statement to include from 1 to 10 lines of text at the top of the report. You can use the FOOTNOTE statement to include from 1 to 10 lines of text at the bottom of the report. In the TITLE statement, you can specify n immediately following the keyword TITLE, to indicate the level of the TITLE statement. n is a number from 1 to 10 that specifies the line number of the TITLE. You must enclose the text of each title in single or double quotation marks. Skipping over some values of n indicates that those lines are blank. For example, if you specify TITLE1 and TITLE3 statements but skip TITLE2, then a blank line occurs between the first and third lines. When you specify a title, SAS uses that title for all subsequent output until you cancel it or define another title for that line. A TITLE statement for a given line cancels the previous TITLE statement for that line and for all lines below it, that is, for those with larger n values. To cancel all existing titles, specify a TITLE statement without the n value: title; To suppress the nthe title and all titles below it, use the following statement: titlen; Footnotes work the same way as titles. In the FOOTNOTE statement, you can specify n immediately following the keyword FOOTNOTE, to indicate the level of the FOOTNOTE statement. n is a number from 1 to 10 that specifies the line number of the FOOTNOTE. You must enclose the text of each footnote in single or double quotation marks. As with the TITLE statement, skipping over some values of n indicates that those lines are blank. Remember that the footnotes are pushed up from the bottom of the report. In other words, the FOOTNOTE statement with the largest number appears on the bottom line. When you specify a footnote, SAS uses that footnote for all subsequent output until you cancel it or define another footnote for that line. You cancel and suppress footnotes in the same way that you cancel and suppress titles. The following program includes titles and footnotes in a report of second quarter sales during the month of April: options linesize=80 pageno=1 nodate; proc sort data=qtr02; by SalesRep;run;
proc print data=qtr02 noobs; var SalesRep Month Units AmountSold; where Month='04'; format Units comma7. AmountSold dollar14.2; sum Units AmountSold; title1 'TruBlend Coffee Makers, Inc.'; title3 'Quarterly Sales Report'; footnote1 'April Sales Totals'; footnote2 'COMPANY CONFIDENTIAL INFORMATION'; run;
Question : Given the raw data record DEPT: ----|----10---|----20---|----30 Printing 750 The following SAS program is submitted: data bonus; infile `dept'; input dept $ 1-11 number 13- 15; $insert statement here$ run; Which SAS statement completes the program and results in a value of `Printing750' for the DEPARTMENT variable? 1. department = dept II number; 2. department = left(dept) II number; 3. department = trim(dept) number; 4. department = trim(dept) put(number,3.);
Correct Answer : 4 The input statement reads the variable dept using 11 bytes. The value of dept (Department) consists of 8 bytes therefore 3 trailing blanks are present in the value of dept which need to be trimmed out using the trim function. This is concatenated to the put function which converts numeric variables to character variables using the supplied format (3.) TRIM (source) The TRIM function produces a value without the trailing blanks in the source. Note: Other rules about trailing blanks in SAS still apply. If the trimmed result is shorter than the length of the variable to which the result is assigned, SAS pads the result with new blanks as it makes the assignment Syntax : PUT(source, format.) source : identifies the constant, variable, or expression whose value you want to reformat. The source argument can be character or numeric. format. : contains the SAS format that you want applied to the value that is specified in the source. This argument must be the name of a format with a period and optional width and decimal specifications, not a character constant, variable, or expression. By default, if the source is numeric, the resulting string is right aligned, and if the source is character, the result is left aligned. To override the default alignment, you can add an alignment specification to a format: -L left aligns the value. -C centers the value. -R right aligns the value. Details : If the PUT function returns a value to a variable that has not yet been assigned a length, by default the variable length is determined by the width of the format. Use PUT to convert a numeric value to a character value. The PUT function has no effect on which formats are used in PUT statements or which formats are assigned to variables in data sets. You cannot use the PUT function to change the type of a variable in a data set from numeric to character. Comparisons : The PUT statement and the PUT function are similar. The PUT function returns a value using a specified format. You must use an assignment statement to store the value in a variable. The PUT statement writes a value to an external destination (either the SAS log or a destination you specify). Example 1: Converting Numeric Values to Character Value In this example, the first statement converts the values of CC, a numeric variable, into the four-character hexadecimal format, and the second writes the same value that the PUT function returns. cchex=put(cc,hex4.); put cc hex4.; Example 2: Using PUT and INPUT Functions In this example, the PUT function returns a numeric value as a character string. The value 122591 is assigned to the CHARDATE variable. The INPUT function returns the value of the character string as a SAS date value using a SAS date informat. The value 11681 is stored in the SASDATE variable. numdate=122591; chardate=put(numdate,z6.); sasdate=input(chardate,mmddyy6.);
Question : The following SAS program is submitted: data one; address1 = `214 London Way'; run; data one; set one; address = tranwrd(address1, `Way', `Drive'); run;
What are the length and value of the variable ADDRESS? 1. Length is 14; value is `214 London Dri'. 2. Length is 14; value is `214 London Way'. 3. Length is 16; value is `214 London Drive'. 4. Length is 200; value is `214 London Drive'.
Correct Answer : 4
Explanation: Syntax TRANWRD(source,target,replacement) Arguments source : specifies a character constant, variable, or expression that you want to translate. target : specifies a character constant, variable, or expression that is searched for in source. Requirement: The length for target must be greater than zero. replacement : specifies a character constant, variable, or expression that replaces target. When the replacement string has a length of zero, TRANWRD uses a single blank instead. Details : Length of Returned Variable In a DATA step, if the TRANWRD function returns a value to a variable that has not previously been assigned a length, then that variable is given a length of 200 bytes. You can use the LENGTH statement, before calling TRANWRD, to change the length of the value. The Basics : The TRANWRD function replaces all occurrences of a given substring within a character string. The TRANWRD function does not remove trailing blanks in the target string and the replacement string. Comparisons : The TRANWRD function differs from the TRANSTRN function because TRANSTRN allows the replacement string to have a length of zero. TRANWRD uses a single blank instead when the replacement string has a length of zero. The TRANSLATE function converts every occurrence of a user-supplied character to another character. TRANSLATE can scan for more than one character in a single call. In doing this scan, however, TRANSLATE searches for every occurrence of any of the individual characters within a string. That is, if any letter (or character) in the target string is found in the source string, it is replaced with the corresponding letter (or character) in the replacement string. The TRANWRD function differs from TRANSLATE in that TRANWRD scans for substrings and replaces those substrings with a second substring.
1. The SORT procedures contain invalid syntax. 2. The merged data sets are not permanent SAS data sets. 3. Access Mostly Uused Products by 50000+ Subscribers 4. The data sets were not merged in the order by which they were sorted.