Hello All,
I'm creating a custom calculated date based on 2 criteria. I was able to create the date however I received this error in the EDIT Calculation pop-up. (in Text view)
Error:
"The expression cannot be saved because an operator is nested too deeply. The current depth is 155 and the maximum depth is 100."
Has anyone else received this error?
Best, Rob
Hello @bobbyfajardo
Looking at your sample code snippet I believe you could completely get rid-off the long conditional IF-THEN logic.
IF ( 'My Season'n = 'Fall' ) RETURN 9 ELSE ( IF ( 'My Season'n = 'Wint' ) RETURN 12 ELSE 3 )
Parse(Substring('ACAD_TERM_DESC'n, 1, 4), 'COMMA5.')
DateFromMDY('My Month'n, 1, 'My Year'n)
IF ( 'STUDENT LIFECYCLE'n In ('Degree Completed') ) RETURN 'My Date'n ELSE .
Please try this approach and let me know how it goes.
Best regards,
Petri
Show the code.
It sounds like you have way too many If/then/else statements. Widgets often have some limitation that code doesn't to help reduce the likelihood of sub-optimal code.
If your date is text and made with text manipulation you are almost certainly doing this the hard way.
Correction: Adding more than 100 on a deep nested operator
Thank you for offering to take a look at my calculated column code. The data is currently on the CAS Server. I would certainly appreciate any assistance on getting this calculated.
I have another option as a back-up. May need to make multiple tabs, but ideally would love to track the lifecycle from any possible beginning to end.
Here's a sample:
IF ( ( 'STUDENT LIFECYCLE STAGE'n In (‘Degree Completed’) ) AND ('ACAD_TERM_DESC'n In ('2010 Fall') ) )
RETURN '1SEP2010'd
ELSE(
IF ( ( 'STUDENT LIFECYCLE STAGE'n In (‘Degree Completed’) ) AND ('ACAD_TERM_DESC'n In ('2011 Fall') ) )
RETURN '1SEP2011'd
ELSE(
I have it down to 126 deep nested operators.
If possible I'd like to do this on the CAS Server using one of the following tools.
SAS Data Studio - "Prepare Data"
SAS Studio - "Develop Code"
Do you have any suggestions as to how a I can make this a code I use in either of the following tools on CAS Server?
I'm trying to keep this column creation on one of the above mentioned tools. This data is real-time.
Thank you, Rob
Hi Rob,
If you have permissions to update the source data in CAS, then I believe either of those tools should enable you to create the column you want. It may be easier and/or more elegant this way.
Within VA, I believe that you might also be able to work around the issue by creating a calculated item to perform part of the logic, and then either a second calculated item or a custom category that is based on the first one to perform the rest. I can't promise this will work as I do not have a 155-deep expression to test with.
Sam
Hello @bobbyfajardo
Looking at your sample code snippet I believe you could completely get rid-off the long conditional IF-THEN logic.
IF ( 'My Season'n = 'Fall' ) RETURN 9 ELSE ( IF ( 'My Season'n = 'Wint' ) RETURN 12 ELSE 3 )
Parse(Substring('ACAD_TERM_DESC'n, 1, 4), 'COMMA5.')
DateFromMDY('My Month'n, 1, 'My Year'n)
IF ( 'STUDENT LIFECYCLE'n In ('Degree Completed') ) RETURN 'My Date'n ELSE .
Please try this approach and let me know how it goes.
Best regards,
Petri
Petri,
This gave me a great headstart!
I had to make some minor edits.
New Calculated Column
MyDate
DateFromMDY(Parse('Term_Month_Char'n, 'COMMA32.'), 1, Parse(
'ACAD_TERM_YR_SIMS'n, 'COMMA32.'))
Much appreciated everyone!
Best, Rob
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.