I think the easiest approach would be to use a macro to iterate the program code for the variables you specify. Something like this should do the trick:
/* Make some data to play with */
data mytable;
input V1:$2. V2:$2. V3:$2. V4:$2. V5:$2. ;
call streaminit (12345);
technical_premium=ROUND(RAND('UNIFORM',10,2));
modeled_loss_costs_uncap_targ=ROUND(RAND('UNIFORM',10,2));
loss_total=ROUND(RAND('UNIFORM',10,2));
resprem_actuarial=ROUND(RAND('UNIFORM',10,2));
ehy=ROUND(RAND('UNIFORM',10,2));
LIAB_amt_bpmdl_wtd=ROUND(RAND('UNIFORM',10,2));
datalines;
A B C D E
B C D E F
B D E F A
C E F A B
D F A B C
E A B C D
F B C E F
A B C D E
B C D E F
B D E F A
C E F A B
D F A B C
E A B C D
F B C E F
;
/**************************************************************
Use a macro for looping the process
Macro accepts 2 parameters:
1. dataset name
2. space-delimited list of variables
**************************************************************/
%macro MakeMyTable(dataset,vars);
%local variable count;
/* Scan through the list of variables, one at a time */
%let count=1;
%let variable=%scan(&vars,&count);
proc sql;
/* If we have a variable name, do the SQL */
%do %while (&variable ne );
create table Univariate_&VARIABLE as
select &VARIABLE
,sum(technical_premium) as TP
,sum(modeled_loss_costs_uncap_targ) as PPxCAT
,sum(loss_total) as PPwCAT
,sum(resprem_actuarial) as prem
,sum(ehy) as count
,calculated PPwCAT - calculated PPxCAT as CAT
,calculated TP - calculated PPwCAT as Other
,sum(LIAB_amt_bpmdl_wtd) as liab
from &DATASET
group by &VARIABLE
;
/* Get the next variable from the list */
%let count=%eval(&count+1);
%let variable=%scan(&vars,&count);
%put _local_;
%end;
quit;
%mend;
/**************************************************************
Use the macro to run the process on mytable for variables
V1 V3 and V5:
**************************************************************/
%makemytable(mytable,V1 V3 V5)
... View more