You are on page 1of 7

STA-201 HW-2

SID-999459827

Problem 2.1: Roman Numerals

O
bs name

part
y

start

end

ag
e

roman_numerals_age

1 Ford

MCMLXXIV

MCMLXXVII

61

MCMXIII

2 Carter

MCMLXXVII

MCMLXXXI

52

MCMXXV

3 Reaga

MCMLXXXI

MCMLXXXI
X

69

MCMXII

4 Bush4

MCMLXXXI
X

MCMXCIII

64

MCMXXV

5 Clinto

MCMXCIII

MMI

46

MCMXLVII

6 Bush4

MMI

MMIX

54

MCMXLVII

7 Obam

MMIX

47

MCMLXII

n
1
n
3
a

Problem 2.2: Change in CPI relative to previous month( printed first 5 observations only)

Ob
s month

date

cpi

change_in_cpi

1534
1

177.
1

1537
2

177.
8

0.7

1540
0

178.
8

1.0

1543
1

179.
8

1.0

1546
1

179.
8

0.0

Problem 2.3: Consumer Price Index test the normality distribution assumption.
The SAS System
The UNIVARIATE Procedure
Variable: change_in_cpi

STA-201 HW-2

N
Mean
Std Deviation
Skewness
Uncorrected
SS
Coeff
Variation

Moments
145 Sum Weights
0.3978 Sum
Observations
0.8782355 Variance
3
- Kurtosis
1.1336079
134.01236 Corrected SS
3
220.77313 Std Error Mean
5

Basic Statistical Measures


Location
Variability
Mean 0.39780 Std Deviation
0
Medi
0.40000 Variance
an
0
Mode 1.00000 Range
0
Interquartile
Range

0.8782
4
0.7713
0
6.5480
0
1.0900
0

Tests for Location: Mu0=0


Test
Statistic
p Value
Student's t t 5.45428 Pr > |t|
<.000
4
1
Sign
M
32.5 Pr >= |
<.000
M|
1
Signed
S
2914 Pr >= |S| <.000
Rank
1
Quantiles (Definition
5)
Quantile
Estimat
e
100% Max
2.400
99%
2.183
95%
1.809
90%
1.334
75% Q3
1.000
50%
0.400
Median
25% Q1
-0.090
10%
-0.477
5%
-0.878
1%
-2.210
0% Min
-4.148

SID-999459827

145
57.681
0.7712976
5
4.7417521
5
111.06686
1
0.0729334
9

STA-201 HW-2

SID-999459827

Extreme Observations
Lowest
Highest
Valu Ob Valu Ob
e
s
e
s
- 83 1.85 63
4.14
3
8
- 82 1.88 13
2.21
6
4
0
- 84 2.15 111
2.19
8
7
- 47 2.18 78
1.60
3
0
- 58 2.40 45
1.10
0
0
Missing Values
Missi Coun
Percent Of
ng
t
All
Missing
Value
Obs
Obs
.
11
7.05
100.00

Conclusion- The distribution looks heavy tailed. Hence the change in CPI doesnt seem to follow a normal
distribution.
Problem 2.4a) The weight used to calculate the average age of presidents.

STA-201 HW-2

SID-999459827

The MEANS Procedure


Analysis Variable : age
N

Mean

Std Dev

Minimu
m

57.1142
857

22.5190
713

46.0000
000

Maximu
m
69.00000
00

b) The data was initially sorted in descending for the variable party and then the average age was calculated
using weights.
party=D

Analysis Variable : age


N

Mean

Std Dev

Minimum

Maximum

48.000000
0

9.797959
0

46.000000
0

52.000000
0

party=R
Analysis Variable : age
N

Mean

Std Dev

61.869565
2

17.536711
0

Minimum

Maximum

54.000000 69.0000000
0

Problem 2.5: The Average percentage of Californians who ride bike to work.

Analysis Variable : Bike_Share_of_Commuters Bike Share


of Commuters
N

Mean

Std Dev

Minimum

Maximum

STA-201 HW-2

439

1.010483
3

405.179739
1

SID-999459827

0 16.6000000

CODE/* creating your own library*/


libname amruta "C:\Users\amrmad\Documents\amruta";
run;
/* Problem 2.1 */
data amruta.presidents;
input name $ party $ start end age ;
datalines;
Ford R 1974 1977 61
Carter D 1977 1981 52
Reagan R 1981 1989 69
Bush41 R 1989 1993 64
Clinton D 1993 2001 46
Bush43 R 2001 2009 54
Obama D 2009 . 47
;
/*Problem 2.2 */
data amruta.romans;
set amruta.presidents;
roman_numerals = start- age;
format start end roman_numerals ROMAN10.;
run;
ods rtf file= 'amruta.romans.rtf';
proc print;
title 'Problem 2.1:Roman Numerals';
run;
ods rtf close;
proc import datafile ="C:\Users\amrmad\Documents\amruta\cpidata2.xls" out=amruta.cpi;
run;
data amruta.cpi_new; /*Converting the data into suitable form */
set amruta.cpi;
drop year--half2;
array monthly{12} jan--dec;
do month = 1 to 12;
date=mdy(month,1,year);
cpi = monthly{month};
output;
end;
data amruta.calculate_cpi; /* Calculate cpi change with the help of the function dif */
set amruta.cpi_new;
/*change_in_cpi = (cpi-lag( cpi ))/cpi;*/
change_in_cpi= dif(cpi);

STA-201 HW-2

SID-999459827

run;
ods rtf file= 'amruta.calculate_cpi.rtf';
proc print data = amruta.calculate_cpi (obs=5);
title 'Problem 2.2:Change in CPI relative to previous month';
run;
ods rtf close;
/* Problem 2.3 */
PROC UNIVARIATE DATA=amruta.calculate_cpi;
QQPLOT change_in_cpi;
HISTOGRAM;*/
RUN;
proc print;
run;
/* Problem 2.4*/
data amruta.presidents1;
set amruta.presidents;
year=end-start;
run;
ods rtf file= 'amruta.presidents1.rtf';
proc means data = amruta.presidents1;
weight year;
var age;
run;
ods rtf close;
proc sort data= amruta.presidents OUT=amruta.democrats ;
BY party ;
RUN ;
data amruta.democrats;
set amruta.democrats;
year= end-start;
run;
proc means data =amruta.democrats;
by party;
weight year;
var age;
run;
/*Problem 2.5*/
proc import datafile ="C:\Users\amrmad\Documents\amruta\bikecommuters.xlsx" out=amruta.bike;
sheet='sheet1';
run;
ods rtf file= 'amruta.bike.rtf';
proc means data = amruta.bike;
weight Total_Workers;
var Bike_Share_of_Commuters;

STA-201 HW-2

run;
ods rtf close;
/*end of code*/

SID-999459827

You might also like