Hi Quentin
You got the result I am looking for. I cannot replicate it apparently. And, outside of the last statement indicated above, there are no differences.
Paul
Please post a full output from a proc contents of your HAVE dataset.
Hi,
Conditional Lag is often problematic. The only values are only written to (and returned from ) the lag queue when it executes.
Some people take the simplistic rule of "Never execute lag() conditionally", to avoid learning how lag works.
would try changing your code to something like:
_lagCNumber=lag(CNumber) ; *execute lag for ever record;
if ExitMonthCategory > .5 then do;
CNumber=_lagCNumber ;
end;
Note also that since you are only computing CNumber for first.&by, it will usually be missing. Perhaps you meant to retain CNumber? That could be a separate issue.
And now, the more I look, the more I'm confused. Could CNumber already exist in your input dataset?
Guess that was just a random collection of thoughts. Maybe post 10 records of what your input dataset looks like, and what you want to get out. Then people may be able to help more. (Apologies if that is what is in the .zip, I can't download it)
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.