BookmarkSubscribeRSS Feed
gretaolsson
Calcite | Level 5

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;

2 REPLIES 2
ballardw
Super User

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.

Rick_SAS
SAS Super FREQ

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.

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