SAS Lecture 8
In BY-group processing, two temporary variables are created for each variable listed in the BY statement. What are the names of the temporary variables?
First.BY-variable and Last.BY-variable where the BY-variable is the name of the variable used in the BY statement
If a data set is not sorted, can it be used as the input data set for BY-group processing?
No, BY-group processing depends on the input data set being sorted.
What happens if you use a character variable with a function that takes numeric arguments?
SAS automatically converts the character value to a numeric value using the w. informat.
List some of the descriptive statistic functions.
SUM, MEAN, MIN, MAX, N, NMISS, and CMISS are some of the descriptive statistic functions
What statement in the DATA step enables BY-Group processing?
The BY statement enables BY-group processing.
What function can be used to remove all occurrences of the character '-' from a string?
The COMPRESS function can be used.
What does the FIND function do?
The FIND function searches a target string for a specified substring.
What are the possible values for those temporary variables?
The First. variable has a value of 1 for the first observation in a BY group; otherwise, it equals 0. The Last. variable has a value of 1 for the last observation in a BY group; otherwise, it equals 0.
What function can be used to convert a character value into a numeric value using a specified informat?
The INPUT function uses an informat to convert a character value into a numeric value.
What function converts all words in a string to have the first letter as uppercase and the remaining letters as lowercase?
The PROPCASE function converts all words in a string into proper case.
What function is used to extract characters from a string?
The SUBSTR function extracts characters from a string.
Describe the effect on Total_Salary if it is used in this statement: Total_Salary + Salary;
Total_Salary is initialized to zero automatically retained increased by the value of Salary for each observation.
Is there ever a case where the values for the First.BY variable and the Last.BY-variable can both be 1?
Yes, this happens when a BY group is composed of a single observation.
What must happen in the DATA step to summarize data by groups? (Circle all that apply.) a. Sort the input data. b. Set the accumulating variable to zero at the start of each BY group. c. Increment the accumulating variable. d. Output only the last observation of each BY group.
b. Set the accumulating variable to zero at the start of each BY group. c. Increment the accumulating variable. d. Output only the last observation of each BY group.
Rewrite sum(Qtr1,Qtr2,Qtr3,Qtr4)to use a numbered range list in place of writing each variable's name.
sum(of Qtr1-Qtr3)
What statement prevents SAS from reinitializing the values in a variable?
Either the RETAIN statement or the sum statement prevents SAS from reinitializing the values in a variable.