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

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?Capture.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

View solution in original post

9 REPLIES 9
DanH_sas
SAS Super FREQ

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

mhollifi
Obsidian | Level 7

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:

Capture.JPG

DanH_sas
SAS Super FREQ

Can you post just the SGPLOT code you're using?

mhollifi
Obsidian | Level 7

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;
DanH_sas
SAS Super FREQ

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.

mhollifi
Obsidian | Level 7

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
      
DanH_sas
SAS Super FREQ

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.

mhollifi
Obsidian | Level 7

Thank you.  It worked.  it's kind of strange why it will plot missing value ... But it worked.  Thanks.

DanH_sas
SAS Super FREQ

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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 9 replies
  • 1568 views
  • 0 likes
  • 2 in conversation