BookmarkSubscribeRSS Feed
GN0001
Barite | Level 11

Hello team,

I can't fix this and it keeps giving me errors. I have worked on this for a long time.

proc summary nway missing data=somename.allofthem;
(where = (MBR_STATE="CA"));
var cnt pos neg;
class Mbr_State;
output out=result_by_state (drop=_TYPE_ _FREQ_) sum=;
run;

2970       proc summary nway missing data=somename.allofthem;
2971        (where = (MBR_STATE="CA"));
            _
            180
170                                                        The SAS System                               14:38 Friday, March 24, 2023

ERROR 180-322: Statement is not valid or it is used out of proper order.
2972         var cnt pos neg;
2973         class Mbr_State;
2974         output out=result_by_state (drop=_TYPE_ _FREQ_) sum=;
2975       run;

Regards,

blue

Blue Blue
26 REPLIES 26
WarrenKuhfeld
Rhodochrosite | Level 12

Your where clause is a data set option. So delete the semicolon in front of it.

 

Tom
Super User Tom
Super User

Make up your mind.

Either use the WHERE= dataset option.

proc summary nway missing data=somename.allofthem(where = (MBR_STATE="CA"));

Or use a WHERE statement.

proc summary nway missing data=somename.allofthem;
 where MBR_STATE="CA";
GN0001
Barite | Level 11
Hello,
It is a where clause. The second one gives errors.
What does data option do? Doesn’t bring same result as where clause?
Blue Blue
GN0001
Barite | Level 11

 

proc summary nway missing data=somename.allofthem;
 where MBR_STATE="CA";

this gives errors. 

Blue Blue
ballardw
Super User

@GN0001 wrote:

 

proc summary nway missing data=somename.allofthem;
 where MBR_STATE="CA";

this gives errors. 


How many times do we have to recommend that when you have errors that you copy the code with the error text and paste it into a text box?

GN0001
Barite | Level 11
I have copied the code and place it in a text box. His is what I see.
Blue Blue
GN0001
Barite | Level 11

Hello, 

I placed it in a text box. It is in a grey text box. Or I can’t understand what you mean.

I took out semicolon from proc summary and the log still shows that I have placed semicolon after proc summary,

This is what I have:
Proc summary….
Var…….;
Class;
Where….;
Run;
The log shows that I have ; after proc summary while I deleted ; 

Blue Blue
Kurt_Bremser
Super User

Open the log window. Mark the complete text from the beginning of the procedure to the final message. Copy it to the clipboard. Open a window here with the </> button. Paste the clipboard contents into it.

GN0001
Barite | Level 11
Please go to very first post. You will see that I placed the log.
Thanks
Blue
Blue Blue
Kurt_Bremser
Super User

@GN0001 wrote:
Please go to very first post. You will see that I placed the log.
Thanks
Blue

You were told where the mistake in that code was. Since you still get an ERROR, we need to see the log from the current code you submit.

GN0001
Barite | Level 11
proc summary data=sashelp.class
where Age = 12;
class sex;
var Height;
output out=class sum=sum;
run;

proc print data=class;
run;
data test1;
set sashelp.class;
run;

The result that I get from this program doesn't seem correct. I assume proc summary can't take a where clause. Just I would like to gain confirmation. 

Thanks

a peach on a tree!

Blue Blue
SASKiwi
PROC Star

Yes you can. Correct your syntax error (missing semicolon):

proc summary data=sashelp.class;
where Age = 12;
class sex;
var Height;
output out=class sum=sum;
run;

SAS 101: SAS statements start with a key word and end in a semicolon.

Tom
Super User Tom
Super User

You can use a where STATEMENT with PROC SUMMARY, just like with almost every other PROC.

 

But you forgot to end your PROC statement before you started the WHERE statement.

proc summary data=sashelp.class;
  where Age = 12;
  class sex;
  var Height;
  output out=class sum=sum;
run;

If you never end the PROC statement then is going to try to treat WHERE and AGE as additional syntax on the PROC SUMMARY statement.  Neither WHERE or AGE are valid parts of the PROC SUMMARY statement.

GN0001
Barite | Level 11

Hello,

thanks for the response. I put semicolon after proc summary, it gives error, really I have changed the location of where and started placing semicolon after proc and then I took it, but no success.

I have be been doing this for three days and no success. 
 Originally the code was like this:

proc summary ….;

var…..;

class….;

where….;

run;

I was running this code for more than two years but all of sudden the word were changed to red and I change the place of where and it edited the code as below:

proc summary….;

where….;

var….;

clas…..;

run;

no success 

I am going crazy!

any tips? 
thanks,

blue

 

 

Blue Blue

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 26 replies
  • 2614 views
  • 5 likes
  • 6 in conversation