0
votes

I am trying to create a graph in SAS Enterprise guide. The data that I am plotting is as follows:

col1  col2    col3
1     12:00    20
2     13:00    30
3     14:00    15
.       .      .
.       .      .
25    24:00    90
26    01:00    25
27    02:00    45
.       .      .
.       .      .
36    11:00    35

I need col2 on horizontal axis and col3 on vertical axis. col1 is reference for col2(time values). The problem is sorting col2. if there is a way i can force the sorting for col2, i think it will work. This what i have

SYMBOL1
    INTERPOL=JOIN
    HEIGHT=10pt
    VALUE=NONE
    LINE=1
    WIDTH=2
    CV = _STYLE_
;
SYMBOL2
    INTERPOL=JOIN
    HEIGHT=10pt
    VALUE=NONE
    LINE=1
    WIDTH=2

    CV = _STYLE_
;
Legend1
    FRAME;
Axis1
    STYLE=1
    WIDTH=1
    MINOR=NONE
    ORDER=0 TO 200 BY 10;
Axis2
    STYLE=1
    WIDTH=1
    ORDER=0 TO 36 BY 1
    MINOR= 
    (NUMBER=1
    );
TITLE;
TITLE1 "test_graph";
FOOTNOTE;
PROC GPLOT DATA = input_data;
PLOT col2 * col3   /
    VAXIS=AXIS1
    HAXIS=AXIS2
FRAME   LHREF=34
CHREF=BLACK
HREF=0 TO 36 BY 1
LEGEND=LEGEND1;
RUN; QUIT;

other than that i tried adding the below statement to force sorting, but it doesn't work.

order=(12:00,13:00,14:00,......23:00,0:00,1:00,2:00,....11:00)

Please advice.

thanks

1
Titles should not be in all caps.crashmstr
will take care of that. thankslearnlearn10
Make your variable a datetime by adding a day, but format it to show only the time. That should get the order you want.Reeza
Thanks Reese ! I have already tried that and it works. But I was looking for a better solution within PROC GPLOT to do that.learnlearn10
Have you tried the values statement? Also, SGPLOT is usually better at graphing these days.Reeza

1 Answers

0
votes

Used the code below and it works fine.

proc sgplot data=input_data ;
    xaxis values=("12:00" "13:00" "14:00"......"23:00" "0:00" "1:00" "2:00"...."11:00")
    label="time";
      yaxis integer values=(0 TO 200 BY 10) label="numb";
      series x=col2  y=col3 ;
    run;