Data visualization with SAS programming

How to eleminate one of annotations for double plot?

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

How to eleminate one of annotations for double plot?

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


Accepted Solutions
Solution
‎02-28-2018 06:13 PM
SAS Super FREQ
Posts: 1,102

Re: How to eleminate one of annotations for double plot?

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


All Replies
Solution
‎02-28-2018 06:13 PM
SAS Super FREQ
Posts: 1,102

Re: How to eleminate one of annotations for double plot?

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

Contributor
Posts: 41

Re: How to eleminate one of annotations for double plot?

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

SAS Super FREQ
Posts: 1,102

Re: How to eleminate one of annotations for double plot?

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

Contributor
Posts: 41

Re: How to eleminate one of annotations for double plot?

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;
SAS Super FREQ
Posts: 1,102

Re: How to eleminate one of annotations for double plot?

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.

Contributor
Posts: 41

Re: How to eleminate one of annotations for double plot?

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
      
SAS Super FREQ
Posts: 1,102

Re: How to eleminate one of annotations for double plot?

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.

Contributor
Posts: 41

Re: How to eleminate one of annotations for double plot?

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

Highlighted
SAS Super FREQ
Posts: 1,102

Re: How to eleminate one of annotations for double plot?

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 188 views
  • 0 likes
  • 2 in conversation