1
votes

I have a data set that has quantitave values by time and type. I wish to summarize these in a different way, so that I can see percntage breakdown of type by time. Here is the data set:

    data have;
    input loc $ prod $ time $ type $ total;
cards;
L1 P1 1 xxx 10
L1 P1 1 yyy 30
L1 P1 1 yyy 60
L1 P2 1 xxx 20
L1 P1 2 xxx 25
L1 P2 2 yyy 60
;
run;

I want to end up with something like this:

loc   prod    type  time1 time2 
L1    P1      xxx   .1    1       
L1    P1      yyy   .9    0       
L1    P2      xxx   1     0
L1    P2      yyy   0     1        

I imagine this will require an array of some sort, but am having trouble sorting out how to get the syntax right. I also thought maybe proc report may work, but not sure. I will need the output to be a dataset.

Thanks for help.

Pyll

1
you can use proc freq to get the percentages. something like: proc freq data=have; by loc prod; tables time*type / out=statout outpct (you want the row percent i think); weight total; run; then you can transpose statout by the loc and prod and type variables, with the time variable as your id variable, and the percent variable as your var variable. i think this is what you want.user27008

1 Answers

1
votes

I will put it in an answer I think is what you want.

proc sort data=have;
by loc prod;
run;

proc freq data=have noprint;
by loc prod;
tables time*type /out=statout outpct;
weight total;
run;

proc sort data=statout;
by loc prod type;
run;

proc tranpose data=statout out=statout2;
by loc prod type;
id time;
var pct_row;
run;