Tricky plot in SAS

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

Tricky plot in SAS

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.


Accepted Solutions
Solution
‎11-24-2013 10:31 PM
Respected Advisor
Posts: 4,649

Re: Tricky plot in SAS

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


All Replies
Solution
‎11-24-2013 10:31 PM
Respected Advisor
Posts: 4,649

Re: Tricky plot in SAS

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
Contributor
Posts: 42

Re: Tricky plot in SAS

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!

Respected Advisor
Posts: 4,649

Re: Tricky plot in SAS

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
Contributor
Posts: 42

Re: Tricky plot in SAS

You are the best!!! Thank you!

☑ This topic is SOLVED.

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

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