08-31-2016 02:29 PM
I need to calculate an OVERALL rate or percentage for my dataset. This involves (summing variable A)/(summing variable B and C).
I have already created new variables:
Now what I want to do is sum_a/sum_bc
However, I don't want to have to create a new variable to do this. I just want to do sum_a/sum_bc. Is there any way to do this? Proc Print? I can't figure it out.
08-31-2016 02:47 PM
I don't eally care where it display, I just want to be able to see the value that it calculates.
I actually also realized that my summing did not work!
How do I sum one entire variable?
this is my code in my data step:
08-31-2016 04:42 PM
Here's one way:
proc means data=sashelp.shoes noprint; output out=want sum(sales inventory returns)=/autolabel; run; title 'Summary of totals'; proc print;run; title 'via data step'; data output; set want; calc = sales / (inventory + returns); run; proc print data=output; format calc percent12.2; run; title 'via proc sql'; proc sql; select sales / sum(inventory, returns) as Percent format=percent12.2 from want; quit;