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 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 758 views
  • 1 like
  • 3 in conversation