Date: Tue, 12 May 1998 13:55:46 -0700
Reply-To: Patricia K Flickner <Patricia.K.Flickner@AEXP.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Patricia K Flickner <Patricia.K.Flickner@AEXP.COM>
Subject: SAS questions
There were some people who couldn't read the attached SAS questions, so I
redid them. Pat
A. Creating a SAS set:
1. What SAS statement would you code to read in an external
raw data file to SAS?
2. How do you read in the variables that you need on that
3. Are you familiar with special input delimiters?If so, how would you
let SAS know what those were?
4. If you're reading in a variable length file with fixed
would you prevent SAS from reading the next record if the
didn't exist on a record?
5. What is the difference between an informat and a format?
6. Name three informats or formats.
7. Name three SAS functions that you have used, if any?
8. How would you code the criteria to restrict the output to
There are a couple of ways to do this.
9. Have you ever used a trailing @? If so, how did you use
10. Have you ever coded a select? If so:
a. When would a select be superior to an if statement?
b. Code a select.
B. Creating external raw data files
1. What statement do you code to tell SAS that it is to write
2. What statement to you code to write the record to the
3. If you're reading in an external file to produce the
external file and
you need to produce the file exactly, do you know the shortcut to write
that record without coding every single variable on the
record? If so,
1. If you're not wanting any SAS output from a data step, how
code the data statement to prevent SAS from producing a set?
2. What is the one statement to set the criteria of data that
coded in any SAS step?
3. Have you ever linked SAS code? If so, describe the link
required statements used to either process the code or the step itself.
4. How would you include common code to be processed along
with your SAS
5. Code a do loop.
6. You are looking for specific data contained somewhere in a
string of 150 bytes. Which function is the best to locate
scan, index, or indexc? Why?
7. If you have a set that contains 100 variables, but you
need only five
of those, what is the code to force SAS to use only those variable?
8. Where is it most efficient to use the statement? Can this
be used anywhere else besides the data step? Where?
9. Have you ever merged two or more SAS sets?
a. Code a merge statement.
b. Code a merge that will keep only the observations that have matches
from both sets.
c. Code a merge that will move the matches of both to
one set, the
non-match of the first set to a second set, and the
the second to a third set.
D. Using SAS sets
1. The data contains variables State, District and County as
variables, along with several numeric variables.
2. Proc Sort
a. Code a Proc Sort.
b. How would you delete duplicate observations?
those of you unfamiliar with the slight problem
process, unless you do a sort on every variable in
duplicate obs that are not back-to-back will not be
simply because this de-duping process compares the current obs
with the previous obs.)
c. How would you delete observations with duplicate
(No problems with this one.)
d. How would you keep SAS from overlaying the a SAS
set with its
3. Proc Freq
a. Code the tables statement for a single-level (most
b. Code the tables statement to produce a multi-level
1) Name the option to produce a frequency
listing rather than a
c. Produce output from the frequency.
d. Restrict the printing of the table.
4. Proc Means
a. Code a Proc Means that show both summed and meaned
output of the data.
b. Code the option that will allow Means to include
data to be included in the report.
c. Code the Means to produce output to be used later.
C. Macro Language
1. Describe how you would create a macrovariable. There are
at least three.
2. If you use a symput in a data step, can you use the
macrovar right away?
3. What do you code to create a macro? End one?
4. Describe how you would pass data to a macro.
5. You have variables 1 thru 5 that need to be processed
would you simplify that processing with a macro?
6. How would you code a macro statement to produce information on the SAS
This statement can be coded anywhere.
7. How do you add a number to a macrovariable?
8. If you need the value of a variable rather than the
variable itself, what
would you use to load the value to a macrovariable?
9. Can you execute a macro within a macro? Describe.
10. Can you create another macro within the macro you are
11. If so, how would SAS know where the current macro ended
and the new one