I want to put value labels in graph. Since it plot using group by, it prints the value label twice. How to eliminate one of them?
Use a small data step to set the value in a the label columns to "" for one of your two group values. Use that data set instead of the original.
Hope this helps!
Dan
Use a small data step to set the value in a the label columns to "" for one of your two group values. Use that data set instead of the original.
Hope this helps!
Dan
Thank you for your reply. But variable that I am plotting is peio1ocd which has same values twice, I cannot make one of the format "".
data look like this:
Can you post just the SGPLOT code you're using?
I am sorry I thought I put the code but it seems disappeared after I put the picture... I am not sure how to use this page well. Anyway, this is the code:
proc sgpanel data = graph2;
panelby natvty / columns=1;
bubble x= foreign y = unemploy size = count /group = educa datalabel = peio1ocd ;
ROWAXIS min=0 max=30;
refline mforeign / axis=x;
refline munemploy;
format peio1ocd peio1ocd.;
run;
The approach I suggested should still work for you. When the string value in peio1ocd is missing (i.e. ""), the BUBBLE plot will just ignore that value for labeling. You do not have to adjust anything with your format.
I am not sure what you mean... I know my interpretation is not right...?
5010
5011 * merge file;
5012 data graph2;
5013 merge educa(in=x) graph1;
5014 by peio1ocd;
5015 if x;
5016 if educa = "high school" then do;
5017 format peio1ocd "";
__
85
200
76
ERROR 85-322: Expecting a format name.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 76-322: Syntax error, statement will be ignored.
5018 end;
5019
5020 run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.GRAPH2 may be incomplete. When this step was stopped there were 0 observations and 10 variables.
WARNING: Data set WORK.GRAPH2 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
No, don't format the value to "", as that will not do what you want. Literally, set the peio1ocd value in the data step to "" if the previous peio1ocd value is the same. This data step should create a temporary data set that you can use with your SGPLOT to drop the labels.
Thank you. It worked. it's kind of strange why it will plot missing value ... But it worked. Thanks.
The reason that the missing value did not affect your plot is that the column was used only for the data labels. The X, Y, SIZE, and GROUP roles control the actual plotting for the BUBBLE plot. In general, missing values in a DATALABEL column are not drawn. That is how you can control what labels are drawn in your plot.
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 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.
Ready to level-up your skills? Choose your own adventure.