BookmarkSubscribeRSS Feed
Neetu
Fluorite | Level 6

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;

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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

--
Paige Miller
Neetu
Fluorite | Level 6

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

ballardw
Super User

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.

Dorota_Jarosz
Obsidian | Level 7

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 833 views
  • 0 likes
  • 4 in conversation