turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- How do I solve Error: Statement is not valid or it...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-07-2017 11:38 AM

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to gretaolsson

04-07-2017 12:29 PM - edited 04-07-2017 12:33 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to gretaolsson

04-07-2017 01:01 PM

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.