PROC SQL ;
CREATE TABLE WORK.query AS SELECT DISTINCT (CLM_DRG_CD) FROM
INP.INP_CLAIMSK_LDS2016 WHERE CLM_DRG_CD='469' OR CLM_DRG_CD='470'
COUNT(CLM_DRG_CD) AS COUNT GROUP BY CLM_DRG_CD;
CONTENTS DATA=WORK.query OUT=WORK.details;
RUN;
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 PROC SQL ;
63 CREATE TABLE WORK.query AS SELECT DISTINCT (CLM_DRG_CD) FROM
64 INP.INP_CLAIMSK_LDS2016 WHERE CLM_DRG_CD='469' OR CLM_DRG_CD='470'
65 COUNT(CLM_DRG_CD) AS COUNT GROUP BY CLM_DRG_CD;
_____
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, AND, EQ,
EQT, GE, GET, GROUP, GT, GTT, HAVING, LE, LET, LT, LTT, NE, NET, OR, ORDER, ^=, |, ||, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
66 CONTENTS DATA=WORK.query OUT=WORK.details;
________
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
67 RUN;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
68
69
70 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
83
Format your code for starters will help to see what doesn't align (and don't use all caps for coding or anything really except emphasis)
proc sql ;
create table work.query as
select distinct (clm_drg_cd) from
inp.inp_claimsk_lds2016
where clm_drg_cd='469' or clm_drg_cd='470'
count(clm_drg_cd) as count /*<- in the wrong place*/
group by clm_drg_cd;
contents data=work.query out=work.details;
run;
This is probably closer to what you're trying to do:
proc sql ;
create table work.query as
select distinct (clm_drg_cd) , count(clm_drg_cd) as count
from
inp.inp_claimsk_lds2016
where clm_drg_cd='469' or clm_drg_cd='470'
group by clm_drg_cd;
quit;
proc contents data=work.query out=work.details;
run;
Format your code for starters will help to see what doesn't align (and don't use all caps for coding or anything really except emphasis)
proc sql ;
create table work.query as
select distinct (clm_drg_cd) from
inp.inp_claimsk_lds2016
where clm_drg_cd='469' or clm_drg_cd='470'
count(clm_drg_cd) as count /*<- in the wrong place*/
group by clm_drg_cd;
contents data=work.query out=work.details;
run;
This is probably closer to what you're trying to do:
proc sql ;
create table work.query as
select distinct (clm_drg_cd) , count(clm_drg_cd) as count
from
inp.inp_claimsk_lds2016
where clm_drg_cd='469' or clm_drg_cd='470'
group by clm_drg_cd;
quit;
proc contents data=work.query out=work.details;
run;
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!
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.