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)

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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