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?
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;
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;
@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?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: