Hi there, I am trying to add the counts above a bar graph, however, I am unfamiliar with the Call BAR function and cannot seem to find any answers online. I used the code provided below.
data SAS_Test; input var1 var2 var3 var4; datalines; 1 . 1 1 0 0 . . . . 1 0 1 . . . 1 0 1 . 1 1 . 1 0 0 1 0 0 1 1 0 1 1 . 1 0 1 0 1 0 1 0 1 0 1 0 1 ; run; proc means data=SAS_Test N NMISS; run; proc iml; varNames = {var1 var2 var3 var4}; use SAS_Test; /* open data set */ read all var varNames into X; /* create numeric data matrix, X */ close SAS_Test; title "Counts of Rows That Contain Missing Values"; Count = countmiss(X,"row"); /* count missing values for each obs */ call Bar(Count); /* create bar chart */ run;
Thank you!
As mentioned in the doc, "The BAR subroutine displays a bar chart by calling the SGPLOT procedure. .... The BAR subroutine is not a comprehensive interface to the SGPLOT procedure. It is intended for creating simple bar charts."
The doc shows how to call the SGPLOT procedure to access any feature that PROC SGPLOT support. For example, you can modify the example in the doc to get this:
create Bar var {'Count'}; append; close Bar; /* write to SAS data set */
submit;
proc sgplot data=Bar; /* create the plot */
vbar Count / datalabel;
run;
endsubmit;
Check CALL BAR() option .
Calling @Rick_SAS
As mentioned in the doc, "The BAR subroutine displays a bar chart by calling the SGPLOT procedure. .... The BAR subroutine is not a comprehensive interface to the SGPLOT procedure. It is intended for creating simple bar charts."
The doc shows how to call the SGPLOT procedure to access any feature that PROC SGPLOT support. For example, you can modify the example in the doc to get this:
create Bar var {'Count'}; append; close Bar; /* write to SAS data set */
submit;
proc sgplot data=Bar; /* create the plot */
vbar Count / datalabel;
run;
endsubmit;
Thank you so much!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.