12-01-2015 11:41 PM - edited 12-01-2015 11:57 PM
I have multiple different data sets, and I am trying to use two at a time for calculations. For instance:
I have a dataset with approximately 90,000 rows, each row has columns: policy , age, gender, loyalty (years with company), smoker, zip code, accidents, premium.
I have another dataset with 6 rows. each row has columns: accidents, Charge.
What I am trying to do is take the accidents from the first dataset for each row and reference that number of accidents with the same number in the second dataset under the accidents column, and then use what is in the charge column for that many accidents (by row) as a multiplier.
I have spent a few hours trying different things and haven't really come up with any solutions.
EDIT: I have uploaded a visual I quickly made to make it easier to understand what I am trying to accomplish
12-02-2015 12:33 AM
12-02-2015 02:00 AM
I'm not having any luck with that info. All I can figure out how to do with a lookup is take an individual policy and perform my desired actions, I need to create a new table with every value from one dataset multiplied by its corresponding value from the other dataset
12-02-2015 04:40 AM
proc sql; create table WANT as select A.*, B.CHARGE, A.ANNUAL_PREMIUM * CHARGE as NEW_PREMIUM from WORK.HAVE A left join WORK.ACCIDENTS on A.ACCIDENTS=B.ACCIDENTS; quit;
12-02-2015 10:26 AM
input policy gender$ age loyalty smoker$ zipcode accidents annual_premium;
2 M 71 1 N 10468 0 1371.05
3 F 63 2 M 10500 1 865.34
input accidents charge;
merge one (in=a)
if a and b;
new_premium = annual_premium*charge;