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

Data Have:

ID ABTIME
156120
1451518
234170
2581118
344230
3661518
487210
4214518
511650
5103418
632660
6433218
778660
7234218
888330
8115618
978220
9236518
1065110
10122218

Want: Plot A*B by ID, and label time point 0 or 18 on each line connected by two points.

For example: line for ID = 1, connecting point (56, 12) and (45,15), then to label (56,12) as from time= 0, and (45,15) from time = 18.

I am stuck on the label, appreciate your great help.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Did you consider using SG graphics?

proc sgplot data=have noautolegend;

series x=a y=b / group=id datalabel=time lineattrs=(pattern=solid color=red);

run;

SGPlot1.png

PG

PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

Did you consider using SG graphics?

proc sgplot data=have noautolegend;

series x=a y=b / group=id datalabel=time lineattrs=(pattern=solid color=red);

run;

SGPlot1.png

PG

PG
peppapig
Calcite | Level 5

This is awesome! Thank you so much! It's working. And I will also add some star or dot data point if sgplot has this type of options. Thank you!

PGStats
Opal | Level 21

Yes, you can easily add markers to both ends. You could perhaps make arrows instead, if that makes sense

/* To add markers */

proc sgplot data=have noautolegend;
series x=a y=b / group=id datalabel=time lineattrs=(pattern=solid color=red)
markers markerattrs=(symbol=circlefilled color=red);
run;

/* To create arrows */

data haveWide;
retain a0 b0;
set have; by id;
if first.id then do;
     a0 = a; b0 = b;
     end;
if last.id then output;
run;

proc sgplot data=havewide noautolegend;
vector x=a y=b / xorigin=a0 yorigin=b0 lineattrs=(pattern=solid color=red);
run;

SGPlot2.png

PG

PG
peppapig
Calcite | Level 5

You are the best!!! Thank you!

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 883 views
  • 0 likes
  • 2 in conversation