SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
pru6
Calcite | Level 5

hello,

I have little SAS experience and has been a challenge doing some data cleaning on my dataset. I have a dataset with 6 years worth of patient healthcare claims (2017-2022). Patients appear multiple times within each year and also reappear in subsequent years. What I want to do is eliminate the duplicates within the year. I was hoping to receive some pointers from this community.

 

My dataset contains  "admit_date" for when they were admitted to receive medical care and  "encounter" (character variable) for the type of level of medical urgency (emergency, outpatient or inpatient). however, say patient 01 was admitted 2 or more times within a week/month as an (outpatient encounter). 

 

I would like to remove duplicates based on urgency level first so that I can then be able to narrow down to at least one "encounter" for every 30 day intervals. Below is a code I tried with the help of a colleague but keep getting an error, mind you this is using SQL but if I can get it done without using SQL that would be great. Thanks in advance.

currently using SAS 9.4

 

proc sql;
create table SSTIs_w_o_Dupadmitdate as
select DISTINCT (admit_date)
from research.Sstis
order by mrn where Encounter not= "Outpatient";
quit;

 

I get the error below

37 proc sql;
38 create table SSTIs_w_o_Dupadmitdate as
39 select DISTINCT (admit_date)
40 from research.Sstis
41 order by mrn where Encounter not= "Outpatient";

                           -----
                            22
                           202
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &, (, *, **, +, ',', -, '.',
/, <, <=, <>, =, >, >=, ?, AND, ASC, ASCENDING, BETWEEN, CONTAINS, DESC, DESCENDING,
EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR,
^, ^=, |, ||, ~, ~=.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

1 REPLY 1
andreas_lds
Jade | Level 19

"order by" must be placed after "where", valid symbols for "not equals" are ne, ^= and some more i can't remember right now.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 562 views
  • 0 likes
  • 2 in conversation