Data visualization with SAS programming

Changing GPLOT to SGPLOT?

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Changing GPLOT to SGPLOT?

Hello,

I am trying to get acquainted with SAS Studio even as I need for my course. I have code for gplot, but none of my instructors know how to use SAS studio either??? Here is the necessary code can anyone help with translating this regression scatter plot to studio speak! 

 

PROC GPLOT DATA=lead;
PLOT iq*miles = first2y / VAXIS=axis1 HAXIS=axis2 LEGEND=legend1;
SYMBOL1 I=rl VALUE=circle COLOR=black LINE=3 WIDTH=2;
SYMBOL2 I=rl VALUE=dot COLOR=black LINE=1 WIDTH=2;
AXIS1 LABEL = (FONT=ARIAL HEIGHT=2.5 ANGLE=90 POSITION=center)
VALUE= (FONT=ARIAL HEIGHT=2;
AXIS2 LABEL = (FONT=ARIAL HEIGHT=2.5 POSITION=center)
VALUE= (FONT=ARIAL HEIGHT=2;
LEGEND1 FRAME LABEL=(FONT=ARIAL HEIGHT= 1.5) VALUE=(FONT=ARIAL HEIGHT=1.5)
POSITION=(bottom inside right) ACROSS=1;
FORMAT first2y yes1no2.;
RUN;


Accepted Solutions
Solution
‎02-25-2016 12:30 AM
SAS Super FREQ
Posts: 925

Re: Changing GPLOT to SGPLOT?

Since your original request was for a regression fit, it requires only a small change to the code given by Reeza:

 

proc sgplot data=lead;
reg x=miles y=iq/group=first2y;
format first2y yes1no2.;
run;

View solution in original post


All Replies
Super User
Posts: 19,167

Re: Changing GPLOT to SGPLOT?

I'm assuming SAS UE, otherwise the following may not apply.

 

Take a look at the Snippets for graphs or the Tasks for graphs. If your graph fits one of those criteria you can use the point and click interface to generate your plot. The code is then available for you to customize. The options tab is there for further customization.

 

DELETE - Graph Tasks.png

 

New Contributor
Posts: 3

Re: Changing GPLOT to SGPLOT?

Yes, I found these choices too, but with all the information presented in the multple regression coupled with the fact that I am just learning that too makes feel like I would not place all the information in the correct places.

Super User
Posts: 19,167

Re: Changing GPLOT to SGPLOT?

There's really only 1 line to copy/recode, the rest is styling and formatting it to look the way you want.

 

PLOT iq*miles = first2y / VAXIS=axis1 HAXIS=axis2 LEGEND=legend1;

Which is in the format

y*x=group

 

So

x=miles

y=iq

Group=first2y

 

 

proc sgplot data=lead;
scatter x=miles y=iq/group=first2y;
format first2y yes1no2.;
run;
New Contributor
Posts: 3

Re: Changing GPLOT to SGPLOT?

Thank you for your help a have been plying with it and found that the scatter plot option gave me what I needed with less confusing options that the regression option
Problem solved for now thank you!
Solution
‎02-25-2016 12:30 AM
SAS Super FREQ
Posts: 925

Re: Changing GPLOT to SGPLOT?

Since your original request was for a regression fit, it requires only a small change to the code given by Reeza:

 

proc sgplot data=lead;
reg x=miles y=iq/group=first2y;
format first2y yes1no2.;
run;
Super User
Super User
Posts: 7,720

Re: Changing GPLOT to SGPLOT?

You will find this website very useful if learning SGPLOT and GTL:

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

 

There are thousands of examples of code for most graph types.  Also, please don't code all in upcase, it makes it very hard to read.  Use consistent casing, indentations etc. (note you can use the {i} symbol above the post to put code in as this keeps formatting), for example:

proc gplot data=lead;
  plot iq*miles = first2y / vaxis=axis1 haxis=axis2 legend=legend1;
  symbol1 i=rl value=circle color=black line=3 width=2;
  symbol2 i=rl value=dot color=black line=1 width=2;
  axis1 label = (font=arial height=2.5 angle=90 position=center) value= (font=arial height=2;
  axis2 label = (font=arial height=2.5 position=center) value= (font=arial height=2;
  legend1 frame label=(font=arial height= 1.5) value=(font=arial height=1.5) position=(bottom inside right) across=1;
  format first2y yes1no2.;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 458 views
  • 0 likes
  • 4 in conversation