BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear

 

I am trying to find a function that i can be used in the second 'if'  statement. Please suggest.Thank you

 

in the second if statement, i am trying to find if all three variables missing or all three variables ='UNKNOWN' then set the 'd' variable missing.

 

my code;

data two;

set one;

if a="NEGATIVE" and b="NEGATIVE" and c="NEGATIVE" then=d='yes';

if cmiss(a,b,c) =3 or (a='UNKNOWN'  and b='UNKNOWN'  and c='UNKNOWN' ) then d='missing';

else d='no';

 

data one;
input a $1-8 b $10-17 c $19-26;
datalines;
NEGATIVE NEGATIVE NEGATIVE
UNKNOWN  UNKNOWN  UNKNOWN
UNKNOWN  
NEGATIVE

;
3 REPLIES 3
PaigeMiller
Diamond | Level 26

@knveraraju91 wrote:

Dear

 

I am trying to find a function that i can be used in the second 'if'  statement. Please suggest.Thank you

 

in the second if statement, i am trying to find if all three variables missing or all three variables ='UNKNOWN' then set the 'd' variable missing.

 


It's not clear to me what the question is. You haven't actually asked a question.

--
Paige Miller
PGStats
Opal | Level 21

I suspect that what you mean to do is :

 

data two;
set one;
if a="NEGATIVE" and b="NEGATIVE" and c="NEGATIVE" then d='yes';
else if cmiss(a,b,c) =3 or (a='UNKNOWN'  and b='UNKNOWN'  and c='UNKNOWN' ) then d='missing';
else d='no';
run;
PG
Astounding
PROC Star

I'm not sure you meant to re-use the variable name D all the time.  But here is an approach you can use.

 

if a=b=c then do;

   if a in (' ', 'NEGATIVE') then d='yes';

   else d='no';

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!

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
  • 661 views
  • 1 like
  • 4 in conversation