BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.

Is there an easy way to create WANT column with data having fields ID, DATE and HAVE column without using lag -

IDDATEHaveWant
A30-Jun-06130-Jun-06
A31-Jul-06130-Jun-06
A31-Aug-06130-Jun-06
A30-Sep-06130-Jun-06
A31-Oct-06130-Jun-06
A30-Nov-060 
A31-Dec-060 
B30-Jun-060 
B31-Jul-060 
B31-Aug-060 
B30-Sep-060 
B31-Oct-06131-Oct-06
B30-Nov-06131-Oct-06
B31-Dec-06131-Oct-06
C30-Jun-060 
C31-Jul-06131-Jul-06
C31-Aug-06131-Jul-06
C30-Sep-060 
C31-Oct-060 
C30-Nov-06130-Nov-06
C31-Dec-06130-Nov-06
1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

Something like this may work (not tested):

data data_want;
  set data_have;
  by id have notsorted;
  if first.have then do;
    if have=1 then want=date;
    else call missing(want);
    end;
  retain want;
run;

View solution in original post

2 REPLIES 2
s_lassen
Meteorite | Level 14

Something like this may work (not tested):

data data_want;
  set data_have;
  by id have notsorted;
  if first.have then do;
    if have=1 then want=date;
    else call missing(want);
    end;
  retain want;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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