Data visualization with SAS programming

Let’s talk graphs. Custom graphs.

Reply
New Contributor
Posts: 2

Let’s talk graphs. Custom graphs.

Hi all,

I started to learn SAS university edition.

When I import .csv file and convert to SAS table, the result will be stored in WORK library. When I close the session and open next time I could not find the table in WORK library. How to do?

 

I am trying to plot Sg plot. I would like to specify major and minor axis grid . I would like to show minor axis and major axis with more division. How do I achive ?  How do I edit graph like I need to draw a line inside the graph write something inside the graph etc after I get regression line 

 

 

 

 

proc sgplot data=work.CAR_DATA;
title 'time vs speed';
scatter x=time y=speed;

 

Thank you for your support.

 

Regards

Govind

 

Super User
Super User
Posts: 7,725

Re: Let’s talk graphs. Custom graphs.

Hi,

 

Question 1: Work is a temporary library pointing to the temporary SAS area, when SAS is closed work is removed.  Set a libname to a physical network path and put data you want to store there.

 

Question 2:  To learn about SGPLOT, or Graph Template Language, rather than me give a long winded example, pop over to this blog.  Examples of all types of graphs, layouts etc. 

http://blogs.sas.com/content/graphicallyspeaking/

SAS Super FREQ
Posts: 3,633

Re: Let’s talk graphs. Custom graphs.

Use the AXIS statements to control grids and tick marks. The GRID option puts grid lines at each tick location. The VALUES= option enables you to specify the location of ticks, like this:

 


proc sgplot data=sashelp.cars;
scatter x=weight y=mpg_city;
xaxis grid values=(2000 to 7000 by 1000);
yaxis grid values=(10 to 60 by 5);
run;

The easiest way to edit a graph and add custom lables, arrows, text boxes, etc, is to use the Graphics Editor. An example and discussion is available in the article "Change a plot title by using the ODS Graphics Editor."

New Contributor
Posts: 2

Re: Let’s talk graphs. Custom graphs.

Dear Rick
I am using university edition. ODS graphic editor is not available . how to enable the ODI graphic editor. .I could not enable minor tick also.I am trying to learn myself the SAS . Thank you for your help
SAS Super FREQ
Posts: 3,633

Re: Let’s talk graphs. Custom graphs.

The GRID and VALUES= options enable you to control the lies and ticks.  You can often use the DATALABELS= option on the SCATTER statement to label individual observations

 

There is also the TEXT statement and the VECTOR statement, which enables you to draw text and arrows at arbitrary locations.

 

You say,  "I need to draw a line inside the graph write something inside the graph etc after I get regression line." Please clarify. Specify what you want to do, perhaps by referring to the graph that I created.   For example, I can add a line to a plot by using the LINEPARM statement, and information about the line by using the INSET statements:

 

proc sgplot data=sashelp.cars;
scatter x=weight y=mpg_city;
lineparm x=0 y=38 slope=-0.005;
inset "Intercept = 38" "Slope = -0.005" / 
       border title="Parameter Estimates" position=topright;
xaxis grid values=(2000 to 7000 by 1000);
yaxis grid values=(10 to 60 by 5);
run;
SAS Super FREQ
Posts: 1,145

Re: Let’s talk graphs. Custom graphs.

[ Edited ]

ODS Graphics Editor is really meant for use for editing of graphs from stat procedures, where you do not have access to the code that made the graph.  When you are using SGPLOT, you can easily change the code yourself, which is better than using Editor.  

 

This is true, except for the free form annotation.  In your case using University Edition, you can add the annotation using the SGANNOTATE feature. See SGF 2016 paper.  Or, you can use any image editor like Microsoft Publisher to add hard coded annotations after the fact.

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