Data visualization with SAS programming

Mark specific graph Node in proc GPLOT?

Accepted Solution Solved
Reply
Regular Contributor
Posts: 161
Accepted Solution

Mark specific graph Node in proc GPLOT?

Hi,

I'm new in SAS/GRAPH facility so I need small help with simple SAS graph:

DATA:

Date:          Time:

05.02.2013 10:01:29

14.02.2013 11:02:01

25.02.2013 10:10:16

03.03.2013 10:24:08

18.03.2013 9:27:40

18.03.2013 9:56:19

18.03.2013 12:18:50

01.04.2013 11:02:41

SAS code:

      symbol1 ci=Blue c=Red i=join v=dot  l=1 w=2;

      proc gplot data=&InTable;

            plot startTime*startDate=1/ AUTOHREF  AUTOVREF;

      run;

Result Graph in attached image.

So what I need is just mark last Graph node in Bold(or in another color etc.) else I'd like automatically add some label to this last Graph node , this label will have concattenated Date and Time value:"01.04.2013 11:02:41"

Thanks!


Graph.bmp

Accepted Solutions
Solution
‎03-19-2013 10:27 AM
Super Contributor
Posts: 543

Re: Mark specific graph Node in proc GPLOT?

hi.

the simplest way I know is to use a small annotate data set.

First you need to sort your data by startDate;

proc sort data = have;by startDate;run;

Then create the annotate data set, where you say if it is the last date then change the color:

data annotate;                                                                                                                             

   length function color $8 text $20;                                                                                                      

   retain xsys ysys '2' when 'a';                                                                                                       

   set have end = _last_;                                                                                                                   

       by startDate;                                                                                                                                

   function='symbol'; 

    xc = startDate

    y =  startTime;

   size=1.3;

   text='dot';

    color = 'blue';

                                                                                                                                     

  /* The symbol color is determined by the value of a variable. */                                                                       

   if (_last_) then do;

        color='green'; size = 2;

   end;

   output;                                                                                                                              

run;

      symbol1 ci=Blue c=Red i=join v=dot  l=1 w=2;

      proc gplot data= have;

            plot starttime*startDate=1/ AUTOHREF  AUTOVREF anno = annotate;

      run;quit;

Good luck!

Anca.

View solution in original post


All Replies
Solution
‎03-19-2013 10:27 AM
Super Contributor
Posts: 543

Re: Mark specific graph Node in proc GPLOT?

hi.

the simplest way I know is to use a small annotate data set.

First you need to sort your data by startDate;

proc sort data = have;by startDate;run;

Then create the annotate data set, where you say if it is the last date then change the color:

data annotate;                                                                                                                             

   length function color $8 text $20;                                                                                                      

   retain xsys ysys '2' when 'a';                                                                                                       

   set have end = _last_;                                                                                                                   

       by startDate;                                                                                                                                

   function='symbol'; 

    xc = startDate

    y =  startTime;

   size=1.3;

   text='dot';

    color = 'blue';

                                                                                                                                     

  /* The symbol color is determined by the value of a variable. */                                                                       

   if (_last_) then do;

        color='green'; size = 2;

   end;

   output;                                                                                                                              

run;

      symbol1 ci=Blue c=Red i=join v=dot  l=1 w=2;

      proc gplot data= have;

            plot starttime*startDate=1/ AUTOHREF  AUTOVREF anno = annotate;

      run;quit;

Good luck!

Anca.

Regular Contributor
Posts: 161

Re: Mark specific graph Node in proc GPLOT?

Hi Anca,

It's exactly what I need, thanks!

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 225 views
  • 0 likes
  • 2 in conversation