Need help in modifying the sas code

Reply
New Contributor
Posts: 4

Need help in modifying the sas code

I am trying to plot the graph for the below table using the following sas code but ending up in error all the time .

can some one suggest me whats wrong.

finish time : Y axis , dy is axis

work.ETL_Logtables is the below table.

finish_time    dy

4:10:31 AM25/07/12
4:19:36 AM24/07/12
4:11:13 AM23/07/12
3:29:20 AM22/07/12
5:32:40 AM21/07/12
4:48:13 AM20/07/12
4:27:11 AM19/07/12
4:55:23 AM18/07/12

data work.ETL_Logtables(keep =dy finish_time) ;

  set work.ETL_Logtables_1

  work.ETL_Logtables_2

  work.ETL_Logtables_3

  work.ETL_Logtables_4

  work.ETL_Logtables_5

  work.ETL_Logtables_6

  work.ETL_Logtables_7

  work.ETL_Logtables_8;

format  start_time finish_time TIMEAMPM11.;

format dy ddmmyy8.;

run;

proc print data =work.ETL_Logtables noobs ;

Title "ETL Logtables timingss";

run;

PROC SORT

     DATA=work.ETL_Logtables(KEEP=finish_time dy)

     OUT=WORK.SORTTempTableSorted

     ;

     BY dy;

RUN;

SYMBOL1

     INTERPOL=JOIN

     HEIGHT=10pt

     VALUE=NONE

     LINE=1

     WIDTH=2

     CV = _STYLE_

;

Axis1

     STYLE=1

     WIDTH=1

     MINOR=NONE

     LABEL=( "TIME" )

;

Axis2

     STYLE=1

     WIDTH=1

     MINOR=NONE

     LABEL=( "DATE" )

;

TITLE;

TITLE1 "Line Plot";

PROC PLOT DATA = WORK.SORTTempTableSorted

;

PLOT dy* finish_time  /

    VAXIS=AXIS1

     HAXIS=AXIS2

FRAME;

RUN; QUIT;

TITLE; FOOTNOTE;

GOPTIONS RESET = SYMBOL;

Trusted Advisor
Posts: 1,612

Re: Need help in modifying the sas code

What error do you get? Can you provide the error portion of your SASLOG?

New Contributor
Posts: 4

Re: Need help in modifying the sas code

I don't get any error but the plot is not as expected

Super User
Posts: 10,497

Re: Need help in modifying the sas code

Try

PROC GPLOT DATA = WORK.SORTTempTableSorted

PROC PLOT is a character type plot suitable for lineprinters and such. It doesn't support symbol or Axis controls.

Contributor
Posts: 66

Re: Need help in modifying the sas code

Hi Neetu,

I think you wanted the days to be on the X axis and finish time on the Y axis. If not, you need to swap the order in the plot statement.

You can comment out the goptions changing the size of the chart, font, etc.

I had to generate some data. Try this code whether it works for you.

data a;
format finish_time TIMEAMPM11. dy ddmmyy8.;
finish_time='04:55:23't;
do dy='18JUL12'd to '25JUL12'd by 1;
  finish_time=finish_time  120*ranuni(0) + 10*ranuni(0);
  output;
  end;
run;
options nocenter nodate byline;
goptions reset=all ftext="Albany AMT" htext=0.35cm ctext=BLACK fontres=presentation border
vsize=4.2in hsize=7.5in noprompt NOGSFPROMPT;

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

Axis1
     STYLE=1
     WIDTH=1
     MINOR=NONE
     LABEL=( "TIME" );

Axis2
     STYLE=1
     WIDTH=1
     MINOR=NONE
     LABEL=( "DATE" );

TITLE;
TITLE2 "Line Plot";
PROC GPLOT DATA = a;
PLOT finish_time*dy / VAXIS=AXIS1 HAXIS=AXIS2 FRAME;
RUN; QUIT;

TITLE2; FOOTNOTE;
GOPTIONS RESET = all;

Each time you generate a plot it is appended to the gseg catalog as Gplot, Gplot1, Gplot2, Gplot3, etc.. You must press page Down to see the last chart. When you want to delete all old plots and start from scratch, submit the following code:

/* delete previously created grsegs before creating new ones */

proc greplay igout=work.gseg nofs;

   delete _all_;

run;

quit;

Ask a Question
Discussion stats
  • 4 replies
  • 318 views
  • 0 likes
  • 4 in conversation