BookmarkSubscribeRSS Feed
user112a2
Obsidian | Level 7

I need help reading the below code. I am not sure what specific parts in this code are doing. For example, what does ( firstobs = 2 keep = DPD_CLOSE_OF_BUSINESS_DT rename = (DPD_CLOSE_OF_BUSINESS_DT = Next_COB_DT) ) do?
Also, what does ( obs = 1 drop = _all_ ); do? I have also not used Prev_COB_DT = ifn( first.SOR_LEASE_NBR, (.), lag(DPD_CLOSE_OF_BUSINESS_DT) ); before, what does this do? I am reading someone elses code, I wish I could provide more detail. If I find a solution, I will post it. Thanks for your help.

 

    Removed
2 REPLIES 2
Kurt_Bremser
Super User

A set statement like this:

set
  LETNOTRG.REQ_1_3_03 (
    firstobs = 2
    keep = DPD_CLOSE_OF_BUSINESS_DT
    rename = (DPD_CLOSE_OF_BUSINESS_DT = Next_COB_DT)
  )
  LETNOTRG.REQ_1_3_03 (
    obs = 1
    drop = _all_
  )
;

performs a "look-ahead" into the dataset by starting to read at observation 2, and preventing a premature eof by reading 1 observation without data (that's what the drop=_all_ does).

What puzzles me is that it tries to read the same dataset that it is creating, so my guess is that this won't work.

Tom
Super User Tom
Super User

It is doing the opposite of LAG().  It is creating a variable that will have the value of a variable from the NEXT observation.

But it is probably using the wrong dataset.  It should be using the same dataset as in the first SET statement.

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
  • 2 replies
  • 796 views
  • 1 like
  • 3 in conversation