BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

Hi,

Is there any way I can check for both the conditions and then output in the same dataset?????

Below I am doing it into seperate datasets and trying to merge later!!!!

ASSUMING BOTH HAVE EQUAL NUMBER OF ELEMENTS!!

Thanks

data vent_array1(keep=visit_id mrn1 vint) vent_array2(keep=visit_id mrn1 vext);

format vint vext datetime.;

set sum_vent;

array intubate{12} itb1-itb12;

array extubate{11} ext1-ext11;

do i=1 to 12;

if admission_date <= intubate{i} AND intubate{i} <= discharged then do;

vint=intubate(i);

output vent_array1;

end;

end;

do i=1 to 11;

if admission_date <= extubate{i} AND extubate{i} <= discharged then do;

vext=extubate(i);

output vent_array2;

end;

end;

run;

2 REPLIES 2
Reeza
Super User

You can flag the observation and then output them instead:

Add in two flag variables as below.

data vent_array1(keep=visit_id mrn1 vint) vent_array2(keep=visit_id mrn1 vext);

format vint vext datetime.;

set sum_vent;

array intubate{12} itb1-itb12;

array extubate{11} ext1-ext11;

flag1=0; flag2=0;

do i=1 to 12 while (flag1 eq 0);

if admission_date <= intubate{i} AND intubate{i} <= discharged then do;

vint=intubate(i);

flag1=1

end;

end;

do i=1 to 11 while (flag2 eq 0) ;

if admission_date <= extubate{i} AND extubate{i} <= discharged then do;

vext=extubate(i);

flag2=1

end;

end;

if flag1 or flag2 =0 then output;

run;

ballardw
Super User

Not sure where you're going with this but if I wanted similar data in one data set I would be strongly tempted to make two additional arrays to hold your VINT and VEXT per intubate for each record instead of creating multiple records.

Something like

Array vint{12} vint1 - vint12;

do i=1 to 12;

if admission_date <= intubate{i} AND intubate{i} <= discharged then vint{i}=intubate{i};

end;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 698 views
  • 3 likes
  • 3 in conversation