ASSIGNMENT #5
Submit the
completed assignment to Canvas. Your code must be general, that is, it must
handle any data meeting these requirements. It cannot rely on features specific
to this data unless specifically noted
below.
You are asked to research a
number of character manipulation operators and functions. The result of this research will be a brief
description of the use, results and limitations of each item on the list as
well as at least one example of its use.
The SCAN function returns the
character string. It returns the word found at the position specified in the
character string provided as input. A word is defined as a character string
between two
delimiters. The default delimiter is a space. Multiple delimiters can be
specified and are treated as a list of possible delimiters – so for instance
specifying “-/” as the delimiter would treat both – and / as delimiters.
Suppose the
contents of the variable text is
“The quick brown fox jumps over the lazy dog”
scan(text,5,’ ‘) returns jumps the 5th word of the
phrase
scan(text,-4,’ ‘) returns over the 4th word from the
end of the phrase
More than one
delimiter can be used:
Suppose textphonenum contains “ (555) 867-5309”
scan(textphonenum,-1,”-()”) returns 5309
Please read and follow the instructions
carefully.
v Questions
1 and 2: Data is in a SAS file – statisticians_orig.sas7bdat
v Question 3:
Data is in raw data file – salaries.xlsx
1.
This question uses the SAS data file
statisticians_orig.sas7bdat (this is already a SAS data file).
a.
Use the appropriate ODS statements to create a
file in Adobe pdf format called formatted.pdf containing only the output
of the print procedure in part b.
b.
Using the print procedure, display each of the
variables (number, name, text, born, died) with the style option in the var
statement to display each variable in a different background color. Make sure
the foreground color is visible against the background color. You may have more
than one var statement in the same print procedure step. For help with
selecting SAS colors, visit this website.
v
Hint: var first / style=[background=purple
foreground=white];
2.
This question also uses the SAS data file
statisticians_orig.sas7bdat (this is already a SAS data file). For each of
parts a through I, write SAS statements to create a new SAS data set called statisticians and adding the following
variables using the specified variable names. Be sure to precede each part of
the data step with a comment giving the part name e.g., 5d, and a brief description
of the task.
a.
The first name of the statistician. Call it first with a length of 25.
b.
The last name of the statistician (the last
word in the name) Call it last with a
length of 25. Note that some the statisticians have two names, some three and
some four. This should be the second if there are two, the third if there are
three and the fourth if there are four, etc.
c.
Using the variables first and last as
computed above, compute the statistician's name in the form first, one space,
last. Call it newfull and assign an appropriate length. Use the strip function to take care of leading and trailing
blanks when defining this variable.
d. Using the
variables first
and
last
as computed above, compute the statistician's name in the form last, a comma,
one space, first. Call it lastfirst and
assign an appropriate length. Ensure
that there are no leading or trailing blanks in this variable.
Get Free Quote!
384 Experts Online