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.
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.
where capacity_refer = '1'
from
sbos_sbl_category
===>
from
sbos_sbl_category
where capacity_refer = '1'
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;
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.