DATA Step, Macro, Functions and more

How do I solve Error: Statement is not valid or it is used out of proper order. (and make loops in)

Reply
Occasional Contributor
Posts: 13

How do I solve Error: Statement is not valid or it is used out of proper order. (and make loops in)

I am completely new to SAS. You can see my code below. When I run the last part, I get the error message:

 

94  95  96 Proc sgplot data = pred;  97 plot p * x_1 = x_2 / vaxis = Axis1 haxis = Axis2;               ____               180  ERROR 180-322: Statement is not valid or it is used out of proper order.

 

 

Why is that? How do I solve it?

 

I also wonder how I can run the same code for several different samples, lets say 300 different samples. Can I make a loop for this and how do I do that? (SAS® Studio university edition) 

 

 

 

PROC IMPORT DATAFILE=REFFILE
DBMS=DBF
OUT=WORK.IMPORT1;
RUN;


proc freq data = WORK.IMPORT1;
tables x_1*(x_2 ytest);
tables x_2*ytest;
weight num;
run;

proc tabulate data = WORK.IMPORT1;
class x_1 x_2 ytest;
tables x_1='x_1', ytest*x_2='x_2'*F=6. / rts=13.;
freq num;
run;

proc logistic data = WORK.IMPORT1 desc;
class x_1 x_2 ytest;
freq num;
model ytest = x_1 x_2;
exact x_1 x_2 / estimate = both;
run;

proc logistic data = WORK.IMPORT1 desc;
class x_1 x_2 ytest;
freq num;
model ytest = x_1 x_2;
exact x_1 x_2 / estimate = both;
output out = pred predicted = p;
run;

symbol1 c=blue v=circle i=join;
symbol2 c=red v=plus i=join;
symbol3 c=black v=square i=join;
axis1 label=(r=0 a=90) minor=none;
axis2 minor=none order=(0 1);
proc sgplot data= pred;
plot p*x_1=x_2 / vaxis=axis1 haxis=axis2;
run;
quit;

Super User
Posts: 11,343

Re: How do I solve Error: Statement is not valid or it is used out of proper order. (and make loops

[ Edited ]
Posted in reply to gretaolsson

With errors it is best to post the code and error from log both and paste into a code box opened with the forum {i] menu icon.

The error message often includes a postional indicator but the main message window will reformat text.

 

But part of your issue is that the HAXIS and VAXIS are not valid for SGPLOT. Did you mean to use Proc GPLOT?

 

 

You should expand on what you mean by "300 samples". If you have a variable, or combination of variables, that describes groups of records that you want processed together then BY group processing is likely what you want.

 

If you mean diffent variables in models and such then likely need to get more details. I suspect an approach with a control dataset containing the variable names as parameters and Call Execute using those parameters would work.

SAS Super FREQ
Posts: 3,755

Re: How do I solve Error: Statement is not valid or it is used out of proper order. (and make loops

Posted in reply to gretaolsson

For PROC SGPLOT, you specify the type of plot you want, and then use keyword-value pairs to specify the variables for each role.  For example, to get a scatter plot of weight vs height with markers colored by the values of Sex variable, you would say

 

proc sgplot data=sashelp.class;
scatter x=height y=weight / group=sex markerattrs=(symbol=CircleFilled);
run;

 

It's a completely different syntax. You might want to look at the ODS Graphics Gallery for examples and code.

Ask a Question
Discussion stats
  • 2 replies
  • 126 views
  • 0 likes
  • 3 in conversation