Can someone explain whats going on in this code?
Can someone explain whats going on in this code (especially the highlighted one)?
It looks to me like it is trying to look for ICU admissions and changes some flag variables based on whether they are found or not.
Can you be more specific about what you want help with. Do you not understand the SAS statements or the logic of the programmer.
Hi Tom,
This is basically the calculation for the "Return to ICU" by the same patient during a single vist(which is identified by the bill number)
It would be great if you can help us understand the logic:
ALSO there is a series of statments like this towards the end.....I had difficulty understanding these toooo!!!!
if (olicuf and not(input(put(dept2,$icud.),f1.0))) then do;
Regards
Work your way out from the lowest level.
PUT(DEPT,$ICUD.) will convert the value of DEPT using the format $ICUD. If you look at the definition of that format it will basically convert DEPT to '1' when it is 'ICU' and everything else to '0'. INPUT(...,F1.0) will convert a one character text string to a number. So the '1' becomes a 1 and the '0' becomes a 0. (NOTE you could have saved one function call if you had defined an INFORMAT that would convert the character strings in DEPT into numbers 0 1. Then you could have just coded INPUT(DEPT,ICUD.). )
NOT (...) . NOT is a logical operator. So if the value in the () is true it becomes false, if it is false it becomes true. SAS treats 0 as false and anything else as true. So the zeros become ones and the ones become zeros. So basically this is saying DEPT is NOT the ICU .
OLICUF AND ... - This is telling SAS to treat variable OLICUF as a boolean value. 0 is false and anything else is true.
So if OLICUF is true and DEPT is NOT the ICU then ....
Hi Could you explain this with a simple dataset.I have a big dataset and could not use the putlog statement to see whats happening i the background
Regards
To try out the complex syntax just write a simple data step and try different values.
data _null_;
do dept2 = 'ICU', 'ER' ;
codestring = put(dept2,$icud.);
codenum = input(codestring,f1.);
notcode = not codenum ;
put (dept2 codestring codenum notcode) (=) ;
end;
run;
To debug the whole program run it for just a few BILL_NUM values .
You could add a WHERE statement to subset (don't overwrite your production dataset!).
Or you could only put to the log for particular cases.
Something like this (you might want to add other variables).
if bill_num = '12345' then putlog (bill_num dept2 olunt olicuf icuctr olicu) (=) ;
You could place it in the various DO/END loops. You might want to adjust the text put to the log so that you can tell which loop is executing.
For example you might use this one after the first DO; statement.
if bill_num = '12345' then putlog 'FIRST.BILL_NUM Loop ' (bill_num dept2 olunt olicuf icuctr olicu) (=) ;
Hi Tom,
Thanks for the reply. I need some more clarification on your explanation of the line of code a couple of days ago...on the NOT Operator
if (olicuf and not(input(put(dept2,$icud.),f1.0))) then do;
ICUtoutf=1;
olicuf=0;
olicu='';
end;
Firstly if it is the first of the bill number and ICU olicuf is given a value 1 and it is retained
the highlighted code is for the dept2 when it is not first of the bill number
Could you now explain me how the NOT logical operator works
billno dept2 olicuf
111 ICU 1
111 AC 1
111 AC 1
I understood it till:
after the format is applied since its not ICU it becomes not (0)
could you explain what happens from there.....
i dint quite get ur explanation on the NOT Logical Operator
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.