2
votes

I want to use proc tabulate to summarize the percentage of beneficiaries that fall under each of the three categorical variable V1-V3 (this is a person level data-set that we're looking at). I have the following proc step which works fine but produces the perentage as PctN_1110, PctN_1100 etc. But I would like to just get one percentage column (which would be kind of the union of the percentage columns provided). I know I can do this in a data-step after the proc step but I wanted to know if there was a way of achieving this in the proc tabulate step. Thanks!

   Proc tabulate date = in_datea
                  Out = out_data;
             Var X1 X2 X3; 
             Table (V1 all) * (V2 all) * (V3 all), N pctn<V3 all>;
    Run;
1
I've rarely found the output of proc tabulate to be useful. It's generally used to prepare output for display. The only way I can see to generate all the stats you want in a single step is a Proc SQL step.Reeza
The reason that I wanted to use Proc Tabulate as opposed to Proc SQL is that it's easy to produce the total (all) rows for each categorical variable. Do you know if there is an easy way of producing the "all" rows using Proc Sql SQL.(I'm kind of new to SAS)user4816715
You're correct, Proc SQL won't do the subtotals or totals nicely. I honestly don't see a way to do this in one step with a decent output table. It depends on what you want to do with the data after as well. You could try proc report, I'd go with proc means + data step.Reeza
OK, Thanks. I'll look into Proc Meansuser4816715
For proc means look at the WAYS/TYPE statements - allow creation of subtotal.Reeza

1 Answers

1
votes
I'm not sure what you are trying to achieve but the below code is based on my understanding of your question.  

 proc format ;

picture mypct low-high='000.00,009.00%';

run;



proc tabulate data=in_data out=out_data;
    class Var X1 X2 X3; 
    tables ((V1 )all),(V2(all)),(v3) 
                        (all)*( N reppctN*f=pctfmt7.1)/rts=20 ;

        run;