LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 1998, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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

SAS Questions:

Base SAS 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 file? 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 input, how would you prevent SAS from reading the next record if the last variable 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 be produced? There are a couple of ways to do this. 9. Have you ever used a trailing @? If so, how did you use it? 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 to an external file? 2. What statement to you code to write the record to the file? 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, describe. C. Misc. 1. If you're not wanting any SAS output from a data step, how would you code the data statement to prevent SAS from producing a set? 2. What is the one statement to set the criteria of data that can be coded in any SAS step? 3. Have you ever linked SAS code? If so, describe the link and any 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 statements? 5. Code a do loop. 6. You are looking for specific data contained somewhere in a character string of 150 bytes. Which function is the best to locate that data: 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 statement 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 non-match of the second to a third set.

D. Using SAS sets 1. The data contains variables State, District and County as the primary variables, along with several numeric variables. 2. Proc Sort a. Code a Proc Sort. b. How would you delete duplicate observations? (Note: for those of you unfamiliar with the slight problem with this process, unless you do a sort on every variable in an observation, duplicate obs that are not back-to-back will not be deleted simply because this de-duping process compares the current obs with the previous obs.) c. How would you delete observations with duplicate keys? (No problems with this one.) d. How would you keep SAS from overlaying the a SAS set with its sorted version? 3. Proc Freq a. Code the tables statement for a single-level (most common) frequency. b. Code the tables statement to produce a multi-level frequency. 1) Name the option to produce a frequency listing rather than a table. 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 missing numeric 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? Explain. 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 identically; how would you simplify that processing with a macro? 6. How would you code a macro statement to produce information on the SAS log? 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 creating? 11. If so, how would SAS know where the current macro ended and the new one began?


Back to: Top of message | Previous page | Main SAS-L page