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)
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.