BookmarkSubscribeRSS Feed
ojinjide0
Calcite | Level 5

Hi!

 

Please advise!

I am unable to use PROC SGPLOT in SAS Studio. I am trying to produce a survival curve. The code seems to work for others using the GPLOT on the non-web based version, however for SAS Studio I get an error message: 

 
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
Here is the code I am using:
 
Proc Sgplot data=temp1; 
Plot survival*NMSB=MMSE/vaxis=axis1 haxis=axis2 legend=legend1;
axis1 order=(0 to 1 by .1)
label=(f=swiss h=2 a=90 "Estimated Survival")
value=(f=swiss h=2);
axis2 order=(0 to 80 by 10)
label=(f=swiss h=2 "Months")
value=(f=swiss h=2);
legend1 label=(h=2 "MMSE")
value=(f=swiss h=2);
run;
6 REPLIES 6
Reeza
Super User
It looks like you've mixed up GPLOT and SGPLOT. They are very different procedures. Your code is GPLOT code, so invalid for SGPLOT. Please refer to the documentation to see the syntax needed for SGPLOT.
ojinjide0
Calcite | Level 5

Hi Reeza,

 

Thank you for replying so quickly! Can I use PROC GPLOT in the online version of SAS? I read several post that said to substitute SGPLOT instead. Is this correct?

 

Also, I didn't see the document syntax that you were referring to. Can you please direct me?

 

Thank you!

 

Nefertiti 

Reeza
Super User
You can use GPLOT in SAS Academics on Demand, you cannot in SAS University Edition (using VirtualBox).

The SGPLOT documentation is here:
https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n0yjdd910dh59zn1toodgupaj4v9.htm&doc...
ballardw
Super User

@ojinjide0 wrote:

Hi!

 

Please advise!

I am unable to use PROC SGPLOT in SAS Studio. I am trying to produce a survival curve. The code seems to work for others using the GPLOT on the non-web based version, however for SAS Studio I get an error message: 

 
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
Here is the code I am using:
 
Proc Sgplot data=temp1; 
Plot survival*NMSB=MMSE/vaxis=axis1 haxis=axis2 legend=legend1;
axis1 order=(0 to 1 by .1)
label=(f=swiss h=2 a=90 "Estimated Survival")
value=(f=swiss h=2);
axis2 order=(0 to 80 by 10)
label=(f=swiss h=2 "Months")
value=(f=swiss h=2);
legend1 label=(h=2 "MMSE")
value=(f=swiss h=2);
run;

Copy the code with the error message from the log. Paste the whole thing into the code box. An Error 180-322 usually has an underscore character under the location of the problem. The code with error and the code box will maintain the formatting to show where the error was found (not always the cause as missing semicolons or mismatched quotes or parentheses prior may be the actual cause).

 

In your case you have apparently just changed the name of existing Proc GPLOT code to SGPLOT. The plot statements are different and AXIS, SYMBOL, PATTERN and LEGEND statements are not used by SGPLOT.

See https://communities.sas.com/t5/SAS-Studio/Switching-from-GPLOT-to-SGPLOT/m-p/516057#M6641 for a related question.

 

SGPLOT uses specific types of plots (many more than GPLOT) with different options. I suspect that instead of

Plot survival*NMSB=MMSE/vaxis=axis1 haxis=axis2 legend=legend1;

you want

 

SCATTER x=nmsb y=survival / group=mmse;

 

ojinjide0
Calcite | Level 5

Hi!  

 

That was helpful, thank you!  Is there a way to replicate this GPLOT code: symbol l=1 i=step v=dot; for the SGPLOT?

 

Thank you

Reeza
Super User
For survival curves you should actually be using the automatic macros to create them. Is there a reason you're not doing that?
They're documented in the SAS/STAT documentation. https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_kaplan_toc.htm&docsetVersion=14.3...

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1454 views
  • 0 likes
  • 3 in conversation