BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bondtk
Quartz | Level 8

Hi

 

I am writing this code and it comes up with this error. using where statement with proc sql...where statement is creating error.

 

Please advise,

 

proc sql;

16 create table summary5 as

17 select

18 state , capacity_refer

19 ,count(*) as num_apps

20

21 where capacity_refer = '1'

from

sbos_sbl_category

group by

 

state , capacity_refer

;

quit;

 

_____

22

76

ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT, FROM, INFORMAT, INTO, LABEL, LEN,

LENGTH, TRANSCODE.

ERROR 76-322: Syntax error, statement will be ignored.

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
Ksharp
Super User

where capacity_refer = '1'

from

sbos_sbl_category

 

===>

 

from

sbos_sbl_category

where capacity_refer = '1'

bondtk
Quartz | Level 8

Hi

 

thanks a lot , it worked. Just a little curious about this one, is there any limitations of where statement.

 

I used this code 1 worked fine,  code 2 brought zero rows, so not sure what happened, is there any better way to write it. code 2 has two additional variables. so code 2 ha created 6 columns and no rows.  code 1 worked well and created 4 columns and 2 rows of data, so I am confused what happened to code.

 

code 1:

 

proc sql;

create table summary6 as

select

 

app_type_flag, ra01, db23

,count(*) as num_apps

from

 

sbos_sbl_category

where

db23 = 1 and

ra01 = 1

 

group by

 

app_type_flag, ra01, db23

;

quit;

 

 

code 2:

 

proc sql;

create table summary5 as

select

 

app_type_flag, ra01, db23 , rb21, re51

,count(*) as num_apps

from

 

sbos_sbl_category

where

db23 = 1 and

ra01 = 1 and

rb21 = 1 and

re51 = 1

 

 

group by

 

app_type_flag, ra01, db23 , rb21 , re51

;

quit;

 

Kurt_Bremser
Super User

There's obviously no observation (row) that meets your expanded where condition. Keep in mind that with "and" all conditions must be true in an observation.

bondtk
Quartz | Level 8
Thanks for the advice, I used or instead and it worked ..

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 15881 views
  • 1 like
  • 3 in conversation