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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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;

View solution in original post

3 REPLIES 3
Ksharp
Super User

Check CALL BAR() option . 

Calling @Rick_SAS 

Rick_SAS
SAS Super FREQ

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;
advmsj
Obsidian | Level 7

Thank you so much!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Multiple Linear Regression in SAS

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 1397 views
  • 2 likes
  • 3 in conversation