BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ranjeeta
Pyrite | Level 9

data stroke_onset;
set EVT.stroke_ischemic;
where SP340_ONSET IS NOT MISSING;
where FIRST_ADM_TM>SP340_ONSET;
by CIHI_KEY_DAD FIRST_ADM_TM;
Window1=(FIRST_ADM_TM-SP340_ONSET)/60;
length cat $100.;
if 0<=Window1<=360 then cat="0to6";
else if 360<Window1=<1440 then cat="6to24";
else if 1440<Window1 then cat = ">24";
else if missing (SP340_ONSET) then cat = "Stroke onset time missing";
else if FIRST_ADM_TM<SP340_ONSET then cat = "Stroke onset after First Admit Time";
else cat='NA';
run;

Hello Can someone advise how I would write the above code i.e. using either the where or if clause to exclude the observations from the output for the bolded categories 

What I have stated in the if then conditions is what I want but now I want to exclude those observations from the output

Also did not want to combine the two where conditions using the and operator since I want to exclude observations for each condition applied separately. Do ijust use subsetting if statements

 

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

WHERE applies to source data.

if you want to delete reservations based on if/assignment statements, you can include a DELETE statement, or an explicit OUTPUT for those observations you wish to save.

Data never sleeps

View solution in original post

5 REPLIES 5
LinusH
Tourmaline | Level 20

WHERE applies to source data.

if you want to delete reservations based on if/assignment statements, you can include a DELETE statement, or an explicit OUTPUT for those observations you wish to save.

Data never sleeps
Ranjeeta
Pyrite | Level 9
I basically did not want the observations for the two bolded if clauses included in stroke_onset dataset
then do I write the code as below:
else if missing (SP340_ONSET) then output Stroke onset time missing;
Ranjeeta
Pyrite | Level 9
Thankyou I included delete in the if then clause Appreciate it
Kurt_Bremser
Super User

Only the last where condition will take effect, so you need to combine both into one with "and".

Once that is done, the two bold else-if are not necessary any longer.

Ranjeeta
Pyrite | Level 9

if I include it using the an in the where then i am not getting the right result as both conditions are applied togetther whereas i wanted to apply both conditions seperately on the source data

Thankyou 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 963 views
  • 1 like
  • 3 in conversation