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;
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.
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.