DATA Step, Macro, Functions and more

selecting dates based on a condition

Reply
Occasional Contributor
Posts: 10

selecting dates based on a condition

data have;
 input Acc  code $ effective_date possession_date;
  datalines;
    1 PO 14JUN2016 29NOV2011

    1 LA  16FEB2012 29NOV2011

    1 LB 14JUN2016 .

    2 LA 29MAR2007 27MAY2010

    2 LB 29MAR2007 28MAY2010       
;
run;

 

From this dataset what I need is if the if the codes are PO or LB and effective date is greater than possesison date the possession_date1 is effective date (of the latest PO or LB codes) else possession_date1 is equal to possession date.

Super User
Super User
Posts: 6,502

Re: selecting dates based on a condition

Can you add what you want the result to look like?

PROC Star
Posts: 552

Re: selecting dates based on a condition

What does your desired output look like? Smiley Happy What happens when there is a missing value?

Occasional Contributor
Posts: 10

Re: selecting dates based on a condition

The output which I require should look like

 

Want

 

Acc Possession_date1

1     29NOV2011

2     29MAR20017

 

The dataset contains either or both of the effective_date and possession_date. If either are missing the popukated date is to be used.

 

Thanks

 

Adnan

Ask a Question
Discussion stats
  • 3 replies
  • 51 views
  • 0 likes
  • 3 in conversation