Sie sind auf Seite 1von 2

EXERCISES CHAPTER 3

1. Use populartours data set from previous exercise set.


country nightsstay airfare staypckgcost tourcompany
France

793 575

Major

Spain

10

805 510

Hispania

India

10

. 489

Peru

722 590

Japan

982 1020 Express


.

Royal
Mundial

Greece

12

748 Express

New Zealand

16 1368 1539 Southsea

Ireland

787

628 Express

Venezuela

426

505 Mundial

Italy

852

598 Express

Russia

14 1106 1024 A-B-C

Switzerland
Australia

816

834 Tour2000

12 1299 1169 Southsea

Brazil

682

610 Almeida

Calculate these variables and list them with PRINT procedure.


Total tour cost airfare + staypckgcost
Daily stay cost staypckgcost / nightsstay

2. Use employees data set from previous exercise set.


----+----1----+----2----+----3----+----4----+----5----+----6
ID

Date1

Date2

Date3

FirstName LastName Salary

312445

12/01/4908/23/5604/29/73 Joe von Mises

$41,230

473941

11/09/5106/21/5903/21/71 John Stevenson $100,459

Calculate the latest month value of Date1, Date2 and Date3 (e.g. December is
later than July.) for each observation.
3. Use the raw data from the file CARS.csv
The names of variables are here:
Make
Model
Type
Origin
DriveTrain
MSRP
Invoice
EngineSize
Cylinders
Horsepower
MPG_City
MPG_Highway
Weight
Wheelbase
Length

Calculate these values, create new variables if necessary:


If MSRP is greater than $50,000; then, the car is too expensive and you
are not interested. Delete all the not-interested cars from the data set.
If Make is BMW or Audi or Acura, you write Yes to Favorite column.
If car is convertible, then change to Convertible in Type column.
If MPGCity > 20 and MPGHighway > 30 then write Economy, otherwise
write Monster to Consumption column.
Create your own criteria for Size in terms of Weight and Length
and categorize the cars into 3 size classes (small, medium, large).
Example: If the weight is less than 2500 and size is less than
180 then small.
Write the maximum horsepowered car upto that car. To be more clear, if
the data set is like:
o Car Horsepower
A
180
B
200
C
150
D
210
Then the answer is:
Car Horsepower MaxHorsepower
A
180
180
B
200
200
C
150
200
D
210
210
Create an array named Mileage of length 2, define MPGCity and
MPGHighway as the values of it. Calculate MixedMileage as
0.4*MPGCity + 0.6*MPGHighway by using the Mileage array.
o

Das könnte Ihnen auch gefallen