BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Paul_NYS
Obsidian | Level 7

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

Reeza
Super User

Please post a full output from a proc contents of your HAVE dataset.

Quentin
Super User

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)

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 17 replies
  • 3433 views
  • 0 likes
  • 5 in conversation