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

One can add symbols in PROC GPLOT as follows.

data _;
do t=1 to 1000;
x+rannor(1);
y+rannor(1);
z+rannor(1);
output;
end;
run;
symbol1 i=join ci=blue v=dot cv=blue;
symbol2 i=join ci=red v=dot cv=red;
symbol3 i=join ci=lime v=dot cv=lime;
proc gplot;
plot (x y z)*t/overlay;
run;

And the following is the outcome.

0.png

But this is too dense if there are a lot of data points. Is it possible to add the symbols sparsely as follows?

1.png

For example, PAST WINNERS in the plot skips many observations and attaches the dots infrequently. Thanks in advance.

P.S. I wonder whether one can add something like the right-most dollar numbers in the sample plot to PROC GPLOT.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You could create another variable that is missing on most of the records from the existing value and assign a symbol that is only the marker, no interpolation

 

data _;
do t=1 to 1000;
x+rannor(1);
y+rannor(1);
z+rannor(1);
/* set value for only a few values of the X*/
if mod(t,50)=0 then q=x;
else q=.;
output;
end;
run;
symbol1 i=join ci=blue v=none cv=blue;
symbol2 i=join ci=red v=none cv=red;
symbol3 i=join ci=lime v=none cv=lime;
symbol4 i=none c=blue  v=dot ;
proc gplot;
plot (x y z q)*t/overlay;
run;

 

And a similar plot with the newer SGPLOT

proc sgplot data=_;
   series x=t y=x/ lineattrs=(color=blue);
   series x=t y=y/ lineattrs=(color=red);
   series x=t y=z/ lineattrs=(color=lime);
   scatter x=t y=q/ markerattrs=(color=blue);
run;
   

 Note that axis labels are controlled differently. SGPLOT uses Xaxis and Yaxis statements and the syntax is different that the device based graphics AXIS statements though some items are similar. Also SGPLOT will add legends differently.

View solution in original post

1 REPLY 1
ballardw
Super User

You could create another variable that is missing on most of the records from the existing value and assign a symbol that is only the marker, no interpolation

 

data _;
do t=1 to 1000;
x+rannor(1);
y+rannor(1);
z+rannor(1);
/* set value for only a few values of the X*/
if mod(t,50)=0 then q=x;
else q=.;
output;
end;
run;
symbol1 i=join ci=blue v=none cv=blue;
symbol2 i=join ci=red v=none cv=red;
symbol3 i=join ci=lime v=none cv=lime;
symbol4 i=none c=blue  v=dot ;
proc gplot;
plot (x y z q)*t/overlay;
run;

 

And a similar plot with the newer SGPLOT

proc sgplot data=_;
   series x=t y=x/ lineattrs=(color=blue);
   series x=t y=y/ lineattrs=(color=red);
   series x=t y=z/ lineattrs=(color=lime);
   scatter x=t y=q/ markerattrs=(color=blue);
run;
   

 Note that axis labels are controlled differently. SGPLOT uses Xaxis and Yaxis statements and the syntax is different that the device based graphics AXIS statements though some items are similar. Also SGPLOT will add legends differently.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 1 reply
  • 490 views
  • 1 like
  • 2 in conversation