BookmarkSubscribeRSS Feed
tlnarayana26
Calcite | Level 5
yearxypercent
201010550%
201123626%
20122528%
201320420%
201417847%
total952526%

The above report gets total and %'s in total column .

(i want 26% in totals)

plz help me

3 REPLIES 3
BrunoMueller
SAS Super FREQ

You can use Proc REPORT to get the output you need. You can make use of the computed column functionality:

<

data have;
  infile cards dlm=",";
 
input
    year x y
  ;
cards;
2010,10,5
2011,23,6
2012,25,2
2013,20,4
2014,17,8
;

proc report data=have nowindows;
 
column year x y myPct;
  define year / display;
 
define x / analysis;
 
define y / analysis;
 
define myPct / computed format=percent9.0;

 
compute myPct;
    myPct = y.sum / x.sum;
 
endcomp;

 
rbreak after / summarize;
run;

/body>

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

proc sql;

     create table WANT as

     select     *

     from       HAVE

     union all

     select     "Total" as YEAR,

                    count(X) as X,

                    count(Y) as Y,

                    round((CALCULATED Y / CALCULATED X) * 100,1.) as PERCENT

     from        HAVE;

quit;

ballardw
Super User

And a Tabulate solution

proc tabulate data=have;

   class year;

   var x y;

   table year='' all='Total',

         x *sum=''*f=best4.     y=''*(sum='y'*f=best4. pctsum<x>='%'*f=best4.)

         /box='Year' ;

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 489 views
  • 0 likes
  • 4 in conversation