BookmarkSubscribeRSS Feed
melgwy
Calcite | Level 5

 

I would like to create a flag to indicate readmission episodes. I started by using SQL to identify all persons in a data set where the difference between their admission (ADMD) and discharge (DISD) dates were between 1 and 30. The resulting data set generated a flag for readmits (Read_Flag) . I then used that information to transpose the Read_Flag by patient:

 

 

proc transpose data=all.readmits4 out=all.reflag_wide prefix=Read_Flag;
by uidnum ;
var Read_Flag;
run;

 

data all.NEW_reflag; 
merge all.reflag_wide all.readmits4a;
by uidnum;
run;

 

proc sort data=all.NEW_reflag nodups; 
by uidnum;
run;

 

data all.NEW_reflag2;
set all.NEW_reflag;
rename Read_Flag1 = index;
run;

 

Everything is ok until I get here:

 

data all.NEW_reflag2;
if index (DISD) - Read_Flag2 (ADMD) >= 30 then RDMT1 =1;
else RDMT1=0;
if if Read_Flag2 (DISD) - Read_Flag3 (ADMD) >= 30 then RDMT2 =1;
else RDMT2=0;
run;

 

Again, I would like to create a flag to indicate readmission episodes (Read_Flag 1 through  Read_Flag 1894) that are more than 30 days apart (with a RDMT flag). I tired the code above however I get a lot of syntax error issues from SAS, plus I'm not sure if I can subtract that the discharge date from one variable with the admission date of another variable. Please advise on the most efficient way to address this issue, Thanks:

3 REPLIES 3
ballardw
Super User

 

If you want to search a string with the index function you need both a source string and target string.

I have no idea what you may be attempting to do here:

if index (DISD) - Read_Flag2 (ADMD) >= 30 then RDMT1 =1;

Read_flag1(ADMD) will mean absolutely nothing to SAS.

If you want to compare the postions of strings you'll need to provide 1) the name of the variable and 2) the value to search for in that variable. It  looks like you may want

 

if index(index,'DISD') - index(Read_flag2,'ADMD') ge 30 then RDMT1=1;

Assuming you meant to search for the string value 'DISD' inside the variable Index and 'ADMD' inside the variable Read_flag2.

 

You may want to consider:

data all.NEW_reflag2;
    set all.NEW_reflag (rename=(Read_Flag1 = index));

 

melgwy
Calcite | Level 5
I will try this,
My goal was to subtract the discharge date (DISD) of my index variable fom the admission (ADMD)date of my Read_flag2 variable.
Does that change your suggestion?
ballardw
Super User

It really helps to provide some data. How do we know what the discharge date of your index variable is? Or the admission date of the Read_flag2? Are they even SAS date values, character or some other numeric that looks vaguely date like.

 

You can use the instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... to create data step code of your All.New_reflag dataset so we can test data against it. But you may still need to tell use how to identify DISD and ADMD.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1121 views
  • 0 likes
  • 2 in conversation