Set to missing if date is a repeat

Accepted Solution Solved
Reply
Super Contributor
Posts: 543
Accepted Solution

Set to missing if date is a repeat

Hi.

How can I set to missing the dates that repeat?

data in;

informat ckd_dt date9.;

format ckd_dt date9.;

input c_id  ckd_dt date9.;

cards;

3021    20SEP2001

3021    20NOV2001

3021    20FEB2002

3021    20FEB2002

3021    20FEB2002

;

data want;

 

3021    20SEP2001

3021    20NOV2001

3021    20FEB2002

3021    .

3021    .

;

Thank you!


Accepted Solutions
Solution
‎01-30-2013 02:22 PM
Super Contributor
Posts: 578

Re: Set to missing if date is a repeat

Posted in reply to AncaTilea

proc sort in=in out=in;

by c_id ckd_dt;

run;

data want;

set in;

by c_id ckd_dt;

if not first.ckd_dt then ckd_dt=.;

run;

View solution in original post


All Replies
Super Contributor
Posts: 543

Re: Set to missing if date is a repeat

Posted in reply to AncaTilea

OK,

I got it.

Thank you.

proc sort data = in;by c_id ckd_dt;

data want;

    set in;

    by c_id ckd_dt;

    if first.ckd_dt then new_dt = ckd_dt;

        else new_dt= .;

run;

:smileyplain:

Solution
‎01-30-2013 02:22 PM
Super Contributor
Posts: 578

Re: Set to missing if date is a repeat

Posted in reply to AncaTilea

proc sort in=in out=in;

by c_id ckd_dt;

run;

data want;

set in;

by c_id ckd_dt;

if not first.ckd_dt then ckd_dt=.;

run;

Super Contributor
Posts: 543

Re: Set to missing if date is a repeat

Thank you.

Once I posted it, I figured it out myself.

Smiley Happy

Super Contributor
Posts: 543

Re: Set to missing if date is a repeat

Posted in reply to AncaTilea

ok,I got it.

Sorry for taking any of your time.

proc sort data = in;by c_id ckd_dt;

data want(drop = ckd_dt rename = (new_dt = ckd_dt))

    set in;

    by c_id ckd_dt;

    if first.ckd_dt then new_dt = ckd_dt;

        else new_dt= .;

run;

Thanks!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 195 views
  • 3 likes
  • 2 in conversation