BookmarkSubscribeRSS Feed
fdrg
Calcite | Level 5

Hello All,

 

Following is my SAS code:

 

proc sgplot data=d;
plot cd*r r*p;
run;

I am not sure why am I getting this error:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 55         
 56         proc sgplot data=d;
 57         plot cd*r r*p;
            ____
            180
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 58         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE SGPLOT used (Total process time):
       real time           0.01 seconds
       cpu time            0.01 seconds
       
 59         
 60         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         

Kindly Help!!!!!!

 

7 REPLIES 7
Reeza
Super User

Plot isn't a valid statement. 

PLOT is for GPLOT procedures not SGPLOT. 

 

You can probably use scatter to get what you want. 

 

Proc SGPLOT data=SASHELP.class;

scatter x=height y=weight;

Run:

 

See the documentation for detailed code examples. 

http://support.sas.com/documentation/cdl/en/grstatproc/69716/HTML/default/viewer.htm#n19gxtzyuf79t3n...

 

PS SAS UE doesn't suppport SAS/Graph procedures such as GPLOT. 

 

fdrg
Calcite | Level 5
Thank you reeza for your reply.
Can you please add as to how can I get a plot of cd*r vs r*p. Coz as per your edit in scatter, I am getting an error. Please help
Reeza
Super User

Post your code and log with errors. 

To have two series add a SCATTER statement for each x/y combination, they'll be automatically overlayed. 

 

This is an example with SERIES but the idea is the same. Note that your common variable should be on the same axis. 

http://support.sas.com/documentation/cdl/en/grstatproc/69716/HTML/default/viewer.htm#n1vkttjoy99wkwn...

fdrg
Calcite | Level 5

Hello Reeza,

 

Here's what I tried:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 55         
 56         proc sgplot data=d;
 57         scatter x=cd*r y=r*p;
                        _     _
                        79    22
                        200   200
 ERROR 79-322: Expecting a Y.
 ERROR 22-322: Syntax error, expecting one of the following: ;, /.  
 ERROR 200-322: The symbol is not recognized and will be ignored.
 58         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE SGPLOT used (Total process time):
       real time           0.02 seconds
       cpu time            0.01 seconds
       
 59         
 60         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72 

Also I am trying to build a line plot. Will series be the same thing that will help me here. I am new to SAS coding hence, such questions. Apologies

Reeza
Super User

You should read the documentation if your unfamiliar with what goes where. 

 

If you look and run my code you'll notice that x is the variable for the x axis and y is the variable for the y axis. 

 

If you want line plots the example I pointed you to is exactly what you want to try and replicate. 

Note which variables go where in the example to modify your code accordingly. Give it another shot and if you have more issue s please post back. 

 

fdrg
Calcite | Level 5
Thank you for all your help reeza. I created two columns in the existing data with cd*r and r*p and then created the scatter plot. Thanks again
Rick_SAS
SAS Super FREQ

Because the PLOT statement is not a valid staetment in PROC SGPLOT. Here is a link to the PROC SGPLOT documentation.

If you are trying to create two scatter plots, you can use the following statements:

proc sgplot data=d;
scatter y=cd x=r;
run;

proc sgplot data=d;
scatter y=r x=p;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1110 views
  • 0 likes
  • 3 in conversation