BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Melk
Lapis Lazuli | Level 10

Is there any way to plot one variable and the row pct for that variable by another (from proq freq) as histogram?

 

Specifically, I have 2 variables, one is continuous that I am treating categorically (1-20) and the other is a binary 0/1 variable. I want to plot the first variable on the x axis and the row percent for the category 1 as the y axis.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

What kind of plot? Scatter, bar, pie, line something else?

 

It may help to remember that the mean of 0/1 coded variable is the percent of 1 values. So with SGPLOT and Hbar or Vbar you could indicate the binary variable as the response variable and request the Stat=mean.

If you must see % symbols then assign a percent format to the binary variable for the plot. No need to use Proc Freq.

 

Other plots likely will require you to summarize the data, (hint: Proc means or Summary with your category variable as Class and the binary as a Var variable).

 

View solution in original post

2 REPLIES 2
ballardw
Super User

What kind of plot? Scatter, bar, pie, line something else?

 

It may help to remember that the mean of 0/1 coded variable is the percent of 1 values. So with SGPLOT and Hbar or Vbar you could indicate the binary variable as the response variable and request the Stat=mean.

If you must see % symbols then assign a percent format to the binary variable for the plot. No need to use Proc Freq.

 

Other plots likely will require you to summarize the data, (hint: Proc means or Summary with your category variable as Class and the binary as a Var variable).

 

Melk
Lapis Lazuli | Level 10

worked beautifully - thank you.

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
  • 2 replies
  • 1398 views
  • 1 like
  • 2 in conversation