Ucsb Pstat 130

ucsb pstat 130
/* PSTAT 130 Homework Winter 2020*/
/* By: */
/* Priscilla Lee */
/* Nivi Lakshminarayanan */
/* Deni Stoyanova */

/* TASK 1: COMPUTATION OF FUTURE COSTS */
/* Instructions 1-11: */

/* 1 */
libname data “/folders/myfolders/Project/Database”;
ucsb pstat 130 get more info ucsb pstat 130
/* proc contents data=data.ptf; run; */

data work.ptf;
set data.ptf;
length age $8 default=8;
today = DATE();
days = today – birthdate;
agenum = floor(days/365);
if (agenum LE 21) then age = “-21”;
if (agenum GT 21) and (agenum LE 35) then age = “21-35”;
ucsb pstat 130 more info ucsb pstat 130
if (agenum GT 35) and (agenum LE 60) then age = “35-60”;
if (agenum GT 60) then age = “+60”;
drop days today agenum;
run;

/* 2 */
proc import datafile=”/folders/myfolders/Project/Database/cars.csv”
out=work.cars
dbms=CSV replace;
getnames=yes;
ucsb pstat 130 click here ucsb pstat 130
datarow=2;
run;

data work.cars;
set work.cars;
informat hp:$15.;
length hp $10;
if (horsepower LE 150) then hp = “low”;
if (horsepower GT 150) and (horsepower LE 300) then hp = “medium”;
if (horsepower GT 300) then hp = “high”;
ucsb pstat 130 read more ucsb pstat 130
run;

proc sort data=work.ptf;
by cars_id;
run;
proc sort data=work.cars;
by cars_id;
run;
ucsb pstat 130 read more ucsb pstat 130

data work.ptf;
merge work.cars work.ptf;
by cars_id;
run;

/* proc print data=ptf (obs=10); */
/* run; */

/* proc print data=ptf (obs=10); */
ucsb pstat 130 website ucsb pstat 130
/* run; */

/* 3 */
proc import datafile=”/folders/myfolders/Project/Database/CA_ZIP_CODE.txt”
out=work.CA_ZIP_CODE
dbms=dlm replace;
getnames=yes;
run;

/* proc print data=CA_ZIP_CODE (obs=10); */
ucsb pstat 130 get more info ucsb pstat 130
/* run; */

data work.CA_ZIP_CODE;
set work.CA_ZIP_CODE;
informat density:$15.;
length density $10;
if (population LE 4000) then density = “low”;
if (population GT 4000) and (population LE 30000) then density = “medium”;
if (population GT 30000) then density = “high”;
run;
ucsb pstat 130 get more info ucsb pstat 130

proc sort data=work.ptf;
by zip_code;
run;

proc sort data=work.CA_ZIP_CODE;
by zip_code;
run;

data work.ptf;
ucsb pstat 130 more info ucsb pstat 130
merge work.CA_ZIP_CODE work.ptf;
by zip_code;
run;
/* density hp and age r importante 🙂 */
/* density hp and age r importante 🙂 */

/* 4 */
data data.claims;
set data.claims;
run;
ucsb pstat 130 get more info ucsb pstat 130

proc sort data=work.ptf;
by POLICYHOLDER_ID POLICY_STARTING_DATE;
run;

proc sort data=data.claims;
by POLICYHOLDER_ID POLICY_STARTING_DATE;
run;

data work.claims;
ucsb pstat 130 get more info ucsb pstat 130
merge data.claims (IN=A) work.ptf (IN=B);
by POLICYHOLDER_ID POLICY_STARTING_DATE;
IF A;
run;

/* 5 */
data work.claims;
set work.claims;
informat year 4.;
ucsb pstat 130 website ucsb pstat 130
year=year(policy_starting_date);
run;

PASTE  Install Cia With Godmode9

proc sort data=work.claims;
by year;
run;

proc means data=work.claims noprint nway;
var CLAIMS_COST;
class year age hp density;
ucsb pstat 130 check here ucsb pstat 130
output out=work.claims_summary (drop = _TYPE_ _FREQ_)
mean(claims_cost) = cost
N(claims_cost) = nb_claims;

/* 6 USE SUM?*/
data work.ptf;
set work.ptf;
format year 4.;
year=year(policy_starting_date);
ucsb pstat 130 more info ucsb pstat 130
run;

proc sort data=work.ptf;
by year;
run;

proc means data=work.ptf noprint nway;
var policyholder_id;
class year age hp density;
output out=work.ptf_summary (drop = _TYPE_ _FREQ_)
ucsb pstat 130 read more ucsb pstat 130
N(policyholder_id) = nb;
run;

/* 7 */
proc sort data=work.claims_summary;
by age density hp year;
run;

proc sort data=work.ptf_summary;
by age density hp year;
ucsb pstat 130 get more info ucsb pstat 130
run;

data work.summary; /* in=a use */
merge work.claims_summary work.ptf_summary;
by age density hp year;
run;

data work.summary;
set work.summary;
informat freq:6.3;
ucsb pstat 130 check here ucsb pstat 130
freq=nb_claims/nb;
run;

/* 8 */
proc sort data=work.summary;
by descending freq age hp density;
run;

proc sort data=work.summary out=work.freq nodupkey;
by age hp density;
ucsb pstat 130 more info ucsb pstat 130
run;

proc sort data=work.freq;
by year age hp density;
run;

proc print data=work.freq;
run;

data work.freq;
ucsb pstat 130 more info ucsb pstat 130
set work.freq;
keep age hp density freq;
run;

/* 9 */
proc sort data=work.summary;
by descending cost age hp density;

proc sort data=work.summary out=work.cost nodupkey;
ucsb pstat 130 check here ucsb pstat 130
by age hp density;
run;

proc sort data=work.cost;
by year age hp density;
run;

/* 10 */
proc sort data=work.cost;
ucsb pstat 130 more info ucsb pstat 130
by age density hp;
run;

proc sort data=work.freq;
by age density hp;
run;

data work.pp;
merge work.cost work.freq;
by age density hp;
ucsb pstat 130 more info ucsb pstat 130
run;

data work.pp;
set work.pp;
informat pp:15.9;
pp=freq*cost;
run;

proc print data=work.pp; run; /*this is 36 observations*/

ucsb pstat 130 website ucsb pstat 130
/* 11 */
data work.pp;
set work.pp;
informat lp: 15.9;
lp = pp*(1+0.05);
run;

/* TASK 2: DEFINITION OF THE BEST INSURANCE PRICE STRATEGY */
/* Instructions 12-19 */

ucsb pstat 130 click here ucsb pstat 130
/* 12 */
data work.price;
set work.pp;
keep age density hp lp;
run;

data work.price;
set work.price;
informat pA: 15.9 pB:15.9 pC:15.9;
pA = lp*(1+0.05);
ucsb pstat 130 more info ucsb pstat 130
pB = lp*(1+0.10);
pC = lp*(1+0.15);
run;

/* 13 */
PROC IMPORT OUT=work.prospect
DATAFILE = “/folders/myfolders/Project/Database/Prospect.csv”
DBMS=CSV
REPLACE;
ucsb pstat 130 get more info ucsb pstat 130
GETNAMES=YES ;
DATAROW=2;
delimiter=”,”;
RUN;

PASTE  Demonfall Script

data work.prospect;
set work.prospect;
length age $8 default=8;
today = DATE();
days = today – birthdate;
ucsb pstat 130 check here ucsb pstat 130
agenum = floor(days/365);
if (agenum LE 21) then age = “-21”;
if (agenum GT 21) and (agenum LE 35) then age = “21-35”;
if (agenum GT 35) and (agenum LE 60) then age = “35-60”;
if (agenum GT 60) then age = “+60”;
drop days today agenum;
run;

proc sort data=work.prospect;
by cars_id;
ucsb pstat 130 website ucsb pstat 130
run;

proc sort data=work.cars;
by cars_id;
run;

data work.prospect;
merge work.cars work.prospect;
by cars_id;
run;
ucsb pstat 130 click here ucsb pstat 130

proc print data=work.prospect (obs=50); run;

proc sort data=work.prospect;
by zip_code;
run;

proc sort data=work.CA_ZIP_CODE;
by zip_code;
run;
ucsb pstat 130 read more ucsb pstat 130

data work.prospect;
merge work.CA_ZIP_CODE work.prospect;
by zip_code;
run;

/* 14 */
proc sort data=work.prospect;
by age density hp;
run;
ucsb pstat 130 click here ucsb pstat 130

proc sort data=work.price;
by age density hp;
run;

data work.prospect;
merge work.prospect work.price;
by age density hp;
run;

ucsb pstat 130 more info ucsb pstat 130
/* 15 */
data work.prospect;
set work.prospect;
informat prob_a:15.9 prob_b:15.9 prob_c:15.9;
prob_a = 1/(1+exp((-0.1*(lp/pA))+(0.002*(pA-lp))));
prob_b = 1/(1+exp((-0.1*(lp/pB))+(0.002*(pB-lp))));
prob_c = 1/(1+exp((-0.1*(lp/pC))+(0.002*(pC-lp))));
run;

ucsb pstat 130 more info ucsb pstat 130
/* 16 */
data work.prospect;
set work.prospect;
informat accept_a:15.9 accept_b:15.9 accept_c:15.9;
if prob_A GT 0.5 then accept_a=1;
else accept_a=0;
if prob_B GT 0.5 then accept_b=1;
else accept_b=0;
if prob_C GT 0.5 then accept_c=1;
else accept_c=0;
ucsb pstat 130 check here ucsb pstat 130
run;

proc print data=work.prospect (obs=100); run;

/* 17 */
proc means data=work.prospect noprint nway;
var accept_a accept_b accept_c;
output out=work.table_volume (drop = _TYPE_ _FREQ_)
sum(accept_a) = A
sum(accept_b) = B
ucsb pstat 130 here ucsb pstat 130
sum(accept_c) = C;
run;

proc print data=work.table_volume (obs=100); run;

/* 18 */
data work.prospect;
set work.prospect;
informat pi_a:15.9 pi_b:15.9 pi_c:15.9;
pi_a = (pA-lp)*accept_a;
ucsb pstat 130 here ucsb pstat 130
pi_b = (pA-lp)*accept_b;
pi_c = (pA-lp)*accept_c;
run;

/* 19 */
proc means data=work.prospect noprint;
var pi_a pi_b pi_c;
output out=work.table_profit (drop = _TYPE_ _FREQ_)
sum(pi_a) = profit_A
ucsb pstat 130 click here ucsb pstat 130
sum(pi_b) = profit_B
sum(pi_c) = profit_C;
run;

/* TASK 3: CREATE A REPORT */
/* Instructions 20-29 */

options nodate pdfpageview=fitpage;
ods noproctitle;
ods pdf style=journal file=”/folders/myfolders/Project/Databse/final_report_lakshminarayanan_lee_stoyanova.pdf”
ucsb pstat 130 click here ucsb pstat 130
startpage=no;

title1 “Homework Project PSTAT 130”;
title2 “Nivi Lakshminarayanan, Priscilla Lee, Deni Stoyanova”;
title3 “[email protected], [email protected], [email protected]”;

ods layout gridded;

/* BEGIN SAS CODE */
/* 21 */
ucsb pstat 130 click here ucsb pstat 130
proc sort data=work.ptf;
by age hp density;
run;

PASTE  Factorio Debug Settings

proc sort data=work.pp;
by age hp density;
run;

data work.ptf_pp ;
merge work.ptf work.pp;
ucsb pstat 130 website ucsb pstat 130
by age hp density;
run;

data work.ptf_pp;
set work.ptf_pp;
where year=2019;
run;

proc print data=work.ptf_pp (obs=100); run;

ucsb pstat 130 here ucsb pstat 130
/* 22 */
title “Average Frequency by Age”;
proc means data=work.ptf_pp mean nonobs;
var freq;
class age;
output out=work.average_claims_freq1 (drop= FREQ TYPE);
types age;
run;

title “Average Frequency by Density”;
ucsb pstat 130 website ucsb pstat 130
proc means data=work.ptf_pp mean nonobs;
var freq;
class density;
output out=work.average_claims_freq2 (drop= FREQ TYPE);
types density;
run;

title “Average Frequency by HP”;
proc means data=work.ptf_pp mean nonobs;
var freq;
ucsb pstat 130 website ucsb pstat 130
class hp;
output out=work.average_claims_freq3 (drop= FREQ TYPE);
types hp;
run;

/* 23 */
title “Average Claims Cost by Age”;
proc means data=work.ptf_pp mean nonobs;
var cost;
class age;
ucsb pstat 130 more info ucsb pstat 130
output out=work.average_claims_cost1 (drop= FREQ TYPE);
types age;
run;

title “Average Claims Cost by Density”;
proc means data=work.ptf_pp mean nonobs;
var cost;
class density;
output out=work.average_claims_cost2 (drop= FREQ TYPE);
types density;
ucsb pstat 130 website ucsb pstat 130
run;

title “Average Claims Cost by HP”;
proc means data=work.ptf_pp mean nonobs;
var cost;
class hp;
output out=work.average_claims_cost3 (drop= FREQ TYPE);
types hp;
run;

ucsb pstat 130 more info ucsb pstat 130
/* 24 */
title “Average Pure Premium of the Current Portfolio”;
proc means data=work.ptf_pp mean nonobs;
var pp;
output out=work.average_pp (drop= FREQ TYPE);
run;

/* 25 */
proc sort data=work.ptf_pp;
by pp;
ucsb pstat 130 website ucsb pstat 130
run;

proc print data=work.ptf_pp (obs=1); var age density hp; run;

/* 26 */
proc sort data=work.ptf_pp;
by descending pp;
run;

proc print data=work.ptf_pp (obs=1); var age density hp; run;
ucsb pstat 130 get more info ucsb pstat 130

/* 27 */
proc print data=work.table_volume label noobs;
label A=”Strategy A” B=”Strategy B” C=”Strategy C”;
run;

/* 28 */
proc print data=work.table_profit label noobs;
label profit_A=”Strategy A” profit_B=”Strategy B” profit_C=”Strategy C”;
run;
ucsb pstat 130 get more info ucsb pstat 130

/* 29 */
data work.final_price;
set work.price;
keep age hp density pA; /* keeping pA since it is the highest profit based on the above instruciton*/
rename pA=best_price;
run;

proc print data=work.final_price noobs; run;

ucsb pstat 130 get more info ucsb pstat 130
/* END SAS CODE */

ods layout end;
ods PDF CLOSE;
ucsb pstat 130

Tags: ucsb pstat 130, www bcfakes com

Leave a Comment