Coding Exercise (Answer)

h

Exercise 1
Create a data set that contains the following variables:
Bank: Bank of America
Rate: 3.23
Year: 5
Name the data set as RATE. 

Answer:
Data Rate;
Bank = "Bank of America";
Rate = 3.23;
Year = 5;
Run;

Exercise 2
Create a data set that contains the following variables:

Save the data set as DEMO.

Answer:
Data Demo;
Length ID $6 Race $9 Gender $6;
Input ID $ Race $ Gender $ Age;
Datalines;
APP001 Black Male 30
APP002 Caucasian Female 25
APP003 Asian Male 24
APP004 Black Female 32
APP005 Caucasian Female 26
;
Run;

Exercise 3
Locate the FISH data set from the SASHelp library. 

Create a subset of the FISH data set and name it as PERCH. PERCH should contain only the observations where SPECIES is reported as "Perch". Save the data set in the WORK library. 

Answer:
Data Perch;
Set SASHelp.Fish;
If Species = "Perch";
Run;