BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

With my code I am  getting my output.

Are there any other way I can  write the code  in the second data step. Thank you

data one;
input date1 date2 date3 date4;
informat date: yymmdd10.;
format date: yymmdd10.;
datalines;
2015-10-01 2015-10-02 2015-10-20 2015-10-12
;
run;

data two;
set one;
if date1 ne . and date2 ne . and date3 ne . and date4 ne . then adt=min(date1,date2,date3,date4);
if adt =date1 or adt =date2 or adt =date3 then edur='recur';
else if adt=date4 then edur='death';
format adt yymmdd10.; run;
3 REPLIES 3
KachiM
Rhodochrosite | Level 12

Look at the example:

data _null_;
   a1 = 10;
   a2 = 5;
   a3 = .;
   y = min(a1,a2,a3);
   put y =;
   if whichN(y, a1,a2,a3) then xx ='recur';
   put xx =;
run;
Reeza
Super User

COALESCE() can come in handy.

Read through the function list, the best way to know what options you have 

PGStats
Opal | Level 21
data two;
set one;
if cmiss(of date:) = 0 then
    edur = choosec(whichn(min(of date:), of date:),"recur","recur","recur","death");
run;
PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 678 views
  • 5 likes
  • 4 in conversation