0
votes

So I have this problem:
I want to very simple plot on x axis put time and on y axis put calculation. But the graphs are always the same.

  • SAS 9.2.
  • sas gplot procedure. Plot statement.

SAS documentation says:

y-variable*x-variable<=n>
plots the values of two variables and can assign a SYMBOL definition to the plot.

But that does not work in given example below.
First generate some data:

data graphData;
    format 
        line $256.
        checkDate yymmddn8. checkTime time.;
    input line $256.;

    dtTime = scan(line,1," ");
    checkDate = input(substr(dtTime,1.8),yymmdd8.);
    checkTime = input(
                catx(":",
                    substr(dtTime,9,2),
                    substr(dtTime,11,2),
                    "00")
                ,time8.);
    load_average_1 = scan(scan(line,-3,","),2,":");
datalines;
201703200800   8:00am  up 56 day(s),  9:36,  0 users,  load average: 0.05, 0.05, 0.05
201703200900   9:00am  up 56 day(s), 10:36,  0 users,  load average: 2.18, 2.27, 2.25
201703201000  10:00am  up 56 day(s), 11:36,  0 users,  load average: 3.92, 4.42, 4.94
201703201100  11:00am  up 56 day(s), 12:36,  0 users,  load average: 1.85, 2.68, 4.19
201703201200  12:00pm  up 56 day(s), 13:36,  1 user,  load average: 2.64, 3.00, 3.09
201703201300   1:00pm  up 56 day(s), 14:36,  1 user,  load average: 3.84, 3.89, 3.65
201703201400   2:00pm  up 56 day(s), 15:36,  1 user,  load average: 1.74, 2.14, 2.32
201703201500   3:00pm  up 56 day(s), 16:36,  1 user,  load average: 1.29, 2.09, 2.96
201703201600   4:00pm  up 56 day(s), 17:36,  0 users,  load average: 3.46, 4.99, 5.29
201703201700   5:00pm  up 56 day(s), 18:36,  0 users,  load average: 3.79, 3.30, 3.74
201703201800   6:00pm  up 56 day(s), 19:36,  0 users,  load average: 2.04, 2.17, 2.45
201703201900   7:00pm  up 56 day(s), 20:36,  0 users,  load average: 2.29, 1.86, 1.57
;
run;

Now the graphs. In plot statement I put checkTime and load_average_1 combinations.

symbol1 color=vibg interpol=join value=dot;

PROC GPLOT DATA=graphdata;
     PLOT checkTime*load_average_1;
     by checkDate;
RUN;

PROC GPLOT DATA=graphdata;
     PLOT load_average_1*checkTime;
     by checkDate;
RUN;

Generated plots: As You can see the plots are the same

enter image description here

2

2 Answers

0
votes

When I run the code in 9.3, the graphs are NOT the same; the axes differ. I would try your code again, maybe add a quit; statement after each run; (shouldn't change anything, but can't hurt.) Maybe try running in batch also. Finally, I would add a different title to each graph, just to make sure you aren't looking at the same graph twice. If you're in DM SAS, the graph viewer does not advance automatically.

title1 "Graph 1: checkTime*load_average_1" ;
PROC GPLOT DATA=graphdata;
 PLOT checkTime*load_average_1;
 by checkDate;
RUN;quit;
title1;

title1 "Graph 2: load_average_1*checkTime" ;    
PROC GPLOT DATA=graphdata;
     PLOT load_average_1*checkTime;
     by checkDate;
RUN;quit;
title1;
0
votes

Update

So it was problem is with graphical option device (goption device).
When DEVICE=ACTIVEX the axis does not switch.
When device is changed to png (Statement: goptions device=png;) graphs are drawn correctly.