BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Phoenix8527
Calcite | Level 5

Here is my dataset. I want to calculate Percentage as Y/(Y+N) using Count number for both NBUS and Season. Anyone know how to get the results?  Thanks a lot

StatusTenureCount
NNBUS543
NSeason1099
YNBUS276
YSeason264
1 ACCEPTED SOLUTION

Accepted Solutions
VD
Calcite | Level 5 VD
Calcite | Level 5

proc sql;

     create table want1 as select

     status, tenure, count, sum(count) as sum

     from have

     group by tenure;

quit;

proc sql;

     create table want2 as select

     status, tenure, count/sum*100 as percent

      from want1

      where status='Y';

quit;

View solution in original post

5 REPLIES 5
DBailey
Lapis Lazuli | Level 10

data have;

input Status $ Tenure $ Count;

cards;

N NBUS 543

N Season 1099

Y NBUS 276

Y Season 264

run;

proc sql;

create table want as

select status, tenure, count, count/sum(count) as Pct

from have;

quit;

Phoenix8527
Calcite | Level 5

The Final result I want to get is 276/(276+543) for NBUS, 264/(264+1099) for Season.

DBailey
Lapis Lazuli | Level 10

proc sql;

create table want as

select status, tenure, count, count/sum(count) as Pct

from have

group by tenure;

quit;

VD
Calcite | Level 5 VD
Calcite | Level 5

proc sql;

     create table want1 as select

     status, tenure, count, sum(count) as sum

     from have

     group by tenure;

quit;

proc sql;

     create table want2 as select

     status, tenure, count/sum*100 as percent

      from want1

      where status='Y';

quit;

data_null__
Jade | Level 19

Times 100.

title "276/(276+543)=%sysevalF(276/(276+543)) for NBUS, 264/(264+1099)=%sysevalF(264/(264+1099)) for Season";
proc freq data=have;
   tables status*tenure / norow nopercent;
  
weight count;
   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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 6256 views
  • 6 likes
  • 4 in conversation