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