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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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