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

Hello

I know this is probably a simple fix, but I cannot get the program to work. I need to make a VBAR graph based off a table sort of like this.

Data work.whatever;
	INFILE	DATALINES	DELIMITER = ',';
	INPUT	StateCd	:$8.
			ColPercent;
	DATALINES;
Ohio,0.51
Delaware,0.0
Alaska,0.59
;

I need the graph to show StateCd as the x-axis and the values of ColPercent as the y-axis, but no matter how I try to code it, I always wind up with each bar showing the frequency (1) and not the value of the variable. How do I get the Ohio bar to show as 0.51 etc?

1 ACCEPTED SOLUTION

Accepted Solutions
James18
Obsidian | Level 7
Hi,
The code below could give you what you are trying to display. There is some unnecessary code that you can take.
My best guess as to why you did not get the results you were looking for is because the response was not set to
ColPercent. I hope this helps!

PROC SGPLOT DATA = Work.whatever;


VBAR StateCd
/ response= ColPercent
GROUPDISPLAY=cluster
DATALABEL = ColPercent;

XAXIS
LABEL = 'State Code'
LABELATTRS = ( SIZE = 9 PT
WEIGHT = BOLD
COLOR = Black );

YAXIS
LABEL = 'Percent'
GRID
LABELATTRS = ( SIZE = 9 PT
WEIGHT = BOLD
COLOR = Black );

RUN;
QUIT;

View solution in original post

2 REPLIES 2
James18
Obsidian | Level 7
Hi,
The code below could give you what you are trying to display. There is some unnecessary code that you can take.
My best guess as to why you did not get the results you were looking for is because the response was not set to
ColPercent. I hope this helps!

PROC SGPLOT DATA = Work.whatever;


VBAR StateCd
/ response= ColPercent
GROUPDISPLAY=cluster
DATALABEL = ColPercent;

XAXIS
LABEL = 'State Code'
LABELATTRS = ( SIZE = 9 PT
WEIGHT = BOLD
COLOR = Black );

YAXIS
LABEL = 'Percent'
GRID
LABELATTRS = ( SIZE = 9 PT
WEIGHT = BOLD
COLOR = Black );

RUN;
QUIT;
ballardw
Super User

@sdevenny wrote:

Hello

I know this is probably a simple fix, but I cannot get the program to work. I need to make a VBAR graph based off a table sort of like this.

Data work.whatever;
	INFILE	DATALINES	DELIMITER = ',';
	INPUT	StateCd	:$11.
			ColPercent;
	DATALINES;
Iowa,0.51
Mississippi,0.0
Utah,0.59
;

I need the graph to show StateCd as the x-axis and the values of ColPercent as the y-axis, but no matter how I try to code it, I always wind up with each bar showing the frequency (1) and not the value of the variable. How do I get the Iowa bar to show as 0.51 etc?


Show some of the code you attempted.

Probably missing Response=variable

 

Has the instructor for your class mentioned how to access the SAS documentation in any flavor?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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