BookmarkSubscribeRSS Feed
sampath
Calcite | Level 5

Can someone explain whats going on in this code?

7 REPLIES 7
sampath
Calcite | Level 5

Can someone explain whats going on in this code (especially the highlighted one)?

Tom
Super User Tom
Super User

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.

robertrao
Quartz | Level 8

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

Tom
Super User Tom
Super User

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

robertrao
Quartz | Level 8

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

Tom
Super User Tom
Super User

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) (=) ;

robertrao
Quartz | Level 8

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 887 views
  • 0 likes
  • 3 in conversation