Can any one knows how to convert below SAS to Pseudo code ?
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.
Giving that awful spaghetti code some visual structure (and removing several unnecessary brackets) makes understanding it much easier:
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
You assign a sum (over several observations, possibly determined by a group by option) to a new variable named con_temp.
This sum is built from the term "temp * SAL_OBL" whenever all the conditions in the when are met.
Hint: this function
intnx('month', "PAR_FEC"d, -1, 'end')
won't work, as the text PAR_FEC is no valid SAS data literal. I suspect this should be a macro variable call &PAR_FEC instead.
Pseudocode just means sort of code. There is no defined standard for what that should be. What you provide there could be pseudocode for how to write an if statement in a datastep for instance. So no, there is no way to provide something you expect which only you know.
Giving that awful spaghetti code some visual structure (and removing several unnecessary brackets) makes understanding it much easier:
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
You assign a sum (over several observations, possibly determined by a group by option) to a new variable named con_temp.
This sum is built from the term "temp * SAL_OBL" whenever all the conditions in the when are met.
Hint: this function
intnx('month', "PAR_FEC"d, -1, 'end')
won't work, as the text PAR_FEC is no valid SAS data literal. I suspect this should be a macro variable call &PAR_FEC instead.
Hi Kurtbremser,
Thanks a lot for your solution.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.