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)

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 2330 views
  • 0 likes
  • 5 in conversation