Need to convert below sas code to pseudocode.

Need to convert below sas code to pseudocode.

sum ((case when (mod_r in ('02') and CAL IN ('P') and fec_in <= intnx('month', "PAR_FEC"d, -1, 'end') and EST not in ('7' '07' ' 7' '7 ' '70')
              and temp>0) then temp*SAL_OBL else . end)) as con_temp.
Amar MAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IanStatisticianCommented:
This is a fragment from SAS's implementation of SQL.  

SQL specifies what you want and not how to do it, so to show this in imperative code to be
ported into another SQL is not going to be strictly possible.

 Any way, what it is saying is to get a value from each record and provide the sum of all of them
 across the whole data set (SQL table). Call the result variable (or SQL column)  con_temp

 what gets summed from each record (or SQL row) is either the result of the calculation
  temp*SAL_OBL
 or the null value.  Adding the null value (here indicated by a dot . ) does not change the sum.

 The condition to add the calculation (and not the null value) is

 mod_r   = '02'                                                             and
 CAL       =  'P'                                                              and
 fec_in <= intnx('month', "PAR_FEC"d, -1, 'end')    and
 EST not in ('7'    '07'    ' 7'    '7 '    '70')                    and
 temp  >  0


 Because these conditions are all joined by  and  they all have to hold simultaneously in a record
 (SQL row).

 The IN condition just says that the value on the left must be one of the list of values
 (in parenthesis) on the right.  For the first 2 conditions there was only one element on the
 right so I replaced the IN ( <single element>) by  = <single element>.

 I strongly suspect you have mistyped the 3rd condition.  Perhaps the "PAR_FEC"d  should
 be "&PAR_FEC"d. Otherwise this would produce a date error.  What the 3rd condition is
 saying is that date value in fec_in   must be equal to or before the end of the
 previous month given by the incorrect parameter  "PAR_FEC"d .

 The 4th condition says that EST  must not be character '7' with or without a
 leading or trailing blank or zero.

 Because this is part of some SQL code there could well be other conditions limiting
 (or expanding) the records (SQL rows) that are subject to the summing.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Statistical Analysis System (SAS)

From novice to tech pro — start learning today.