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

This really shouldn't be so difficult. Maybe my brain is still in weekend mode. I have a table of students and four columns (Graduated, Transferred, Grad&Trans, GradOrTrans) that have 0 or 1 depending on if they graduated and/or transferred. How can I make a bargraph that shows the percentage of 1's in each column?

Thanks,

Brian

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Here's an example using SASHELP.CLASS. This assumes you have SAS 9.3+ to use the STACKODS option and the concept that the average of a binary variable is the same as the percent (though that's not shown here).

proc means data=sashelp.class stackods mean;

var age weight height;

ods table Summary=Summary1;

run;

proc sgplot data=summary1;

vbarparm  category=variable response=mean;

run;quit;

View solution in original post

3 REPLIES 3
AncaTilea
Pyrite | Level 9

Something like this would work:

data in;

input status group $;

datalines;

1 G

1 T

1 G&T

1 GorT

1 G

1 G

1 G

0 T

0 T

0 GorT

0 GorT

0 GorT

1 GorT

1 GorT

1 GorT

1 G&T

0 G&T

0 G&T

0 G&T

0 G&T

0 G

1 T

1 T

1 G

;

PROC FREQ DATA = IN;TABLES GROUP;RUN;

PROC GCHART DATA = IN;

    VBAR GROUP/SUMVAR = STATUS PCT;

RUN;QUIT;

There are more options to enhance the graph...but to get you started.

Good luck,

Anca.

Reeza
Super User

Here's an example using SASHELP.CLASS. This assumes you have SAS 9.3+ to use the STACKODS option and the concept that the average of a binary variable is the same as the percent (though that's not shown here).

proc means data=sashelp.class stackods mean;

var age weight height;

ods table Summary=Summary1;

run;

proc sgplot data=summary1;

vbarparm  category=variable response=mean;

run;quit;

BTAinRVA
Quartz | Level 8

Reeza,

I learned something new today! Makes it all worthwhile.

Thanks,

Brian

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
  • 996 views
  • 3 likes
  • 3 in conversation