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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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