HI,
I have a file with heaps of patients, their admission dates and re-admission dates. I want to calculate the % of re-admission within 3 months. If the patient has multiple re-admission then I want it to calculate from the first admission date.
How do I use or create a formula for it.
Data example -
PLEASE SEE ATTACHED
Please post example data as data step code with datalines. Nobody likes having to type text from pictures, and not knowing the correct variable attributes makes finding the right solution even harder.
Also post an example for the expected result from that dataset.
Please see the attached file.
Would love to see the output something like -
| OUTPUT | ||||||||
| EPISODE_ID | ADMISSION_NUM | ADMISSION_DATE_ID | PAT_UR_NUM | DISCHARGE_DATE_ID | DAYS | DRG_CODE_VER_042 | RE-ADMISSION COUNT IF WITHIN 3 MONTHS | |
| 28-104840 | 104840 | 2015-08-31 | 5933 | 2015-09-25 | 25 | U66Z | 0 | |
| 28-106124 | 106124 | 2015-09-29 | 5933 | 2015-10-22 | 52 | U66Z | 1 | |
| 28-79790 | 79790 | 2014-04-03 | 6709 | 2014-05-04 | 31 | U66Z | 1 | |
| 28-82421 | 82421 | 2014-05-16 | 6709 | 2014-05-17 | 44 | U66Z | 1 | |
| 28-83433 | 83433 | 2014-06-05 | 6709 | 2014-06-13 | 71 | U66Z | 1 |
ID
Please READ my post.
DATA.STEP.WITH.DATALINES.
Excel files are useless for representing SAS datasets. No types, defined lengths, formats. And many corporate sites block their download from the internet.
With the macro from my footnote, converting a SAS dataset to a data step is done in the same time you need for the export to Excel, and we get something we can use.
So your first step will not be some fancy programming, but creating a usable SAS dataset from the data in that spreadsheet.
Then use the macro from my footnotes to convert it to a data step, or write that step yourself. Preparing example or simulation data is an extremely useful SAS skill in itself.
Help us help you. If you can properly supply the data, then forum participants can help develop a solution. If you provide a picture of the data or a spreadsheet of the data, you are effectively outsourcing the proper creation of the topic, whereas the best forum convention is outsourcing only the solution.
I'm surprised that you can't link to the "how to post code" url provided by @Kurt_Bremser's. In short you would benefit by posting code and data that look like this:
data have;
infile datalines dlm=',';
input episode_??. id ?? admission_num ?? pat_ur_num ??
admission_date_id ?? discharge_date_id ?? days ??;
datalines;
28-104840, 104840, 5933, 2015-08-31, 2015-09-25, .
.....
28-123468,123468,7721,2017-01-06,2017-10-20,.
run;
You will need to (1) fill in the data where I inserted the ellipsis, and (2) fill in proper informats where I have inserted ??. Then people can not only suggest solutions, but test their suggestions prior to responding.
"How to convert datasets to data steps". It's the second of my three footnotes.
@Nikhil28 wrote:
Sorry couldn’t see the footnote to convert it into data step.
In the interest of moving things along, here's a DATA step with the data lines. I generated this in EG by using the Import Data task, and then selected to include the records as data lines in the program.
/* --------------------------------------------------------------------
Code generated by a SAS task
-------------------------------------------------------------------- */
/* --------------------------------------------------------------------
This DATA step reads the data values from DATALINES within the SAS
code. The values within the DATALINES were extracted from the text
source file by the Import Data wizard.
-------------------------------------------------------------------- */
DATA WORK.READMIT;
LENGTH
EPISODE_ID $ 9
ADMISSION_NUM 8
ADMISSION_DATE_ID 8
PAT_UR_NUM 8
DISCHARGE_DATE_ID 8
DRG_CODE_VER_042 $ 4 ;
FORMAT
EPISODE_ID $CHAR9.
ADMISSION_NUM BEST6.
ADMISSION_DATE_ID DATE9.
PAT_UR_NUM BEST4.
DISCHARGE_DATE_ID DATE9.
DRG_CODE_VER_042 $CHAR4. ;
INFORMAT
EPISODE_ID $CHAR9.
ADMISSION_NUM BEST6.
ADMISSION_DATE_ID DATE9.
PAT_UR_NUM BEST4.
DISCHARGE_DATE_ID DATE9.
DRG_CODE_VER_042 $CHAR4. ;
INFILE DATALINES4
DLM=','
MISSOVER
DSD ;
INPUT
EPISODE_ID : $CHAR9.
ADMISSION_NUM : ?? BEST6.
ADMISSION_DATE_ID : ?? DATE9.
PAT_UR_NUM : ?? BEST4.
DISCHARGE_DATE_ID : ?? DATE9.
DRG_CODE_VER_042 : $CHAR4. ;
DATALINES4;
28-60030,60030,15FEB2013,124,08MAR2013,U66Z
28-142929,142929,04JUL2018,1442,20AUG2018,U66Z
28-124021,124021,30JAN2017,5650,16MAR2017,U66Z
28-104840,104840,31AUG2015,5933,25SEP2015,U66Z
28-106124,106124,29SEP2015,5933,22OCT2015,U66Z
28-129352,129352,16JUN2017,6068,21AUG2017,U66Z
28-57751,57751,10JAN2013,6170,31JAN2013,U66Z
28-66130,66130,13JUN2013,6184,28JUN2013,U66Z
28-59972,59972,14FEB2013,6349,18MAR2013,U66Z
28-61234,61234,07MAR2013,6385,20MAR2013,U66Z
28-63178,63178,12APR2013,6427,13APR2013,U66Z
11-488117,488117,11NOV2017,6527,09DEC2017,U66Z
11-515347,515347,29MAY2018,6527,22JUN2018,U66Z
28-68397,68397,05AUG2013,6557,16AUG2013,U66Z
28-110635,110635,22JAN2016,6648,09FEB2016,U66Z
28-79790,79790,03APR2014,6709,04MAY2014,U66Z
28-82421,82421,16MAY2014,6709,17MAY2014,U66Z
28-83433,83433,05JUN2014,6709,13JUN2014,U66Z
28-85484,85484,08JUL2014,6709,20AUG2014,U66Z
28-88149,88149,29AUG2014,6709,12SEP2014,U66Z
28-72646,72646,13NOV2013,6732,22NOV2013,U66Z
28-73012,73012,20NOV2013,6750,19DEC2013,U66Z
28-73191,73191,21NOV2013,6753,25NOV2013,U66Z
;;;;
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.