[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: SAS-L Digest - 5 Jan 2022 to 6 Jan 2022 (#2022-7)
From:       Tim Berryhill <000008c2afdd9bfa-dmarc-request () LISTSERV ! UGA ! EDU>
Date:       2022-01-06 15:14:51
Message-ID: f9eabb2995924c9e8e7f39bdf85ce7d4 () wellsfargo ! com
[Download RAW message or body]

Greg, Is there a typo in the line " else if (q3_1 =1 and q3_1 ^=.) "?  Was a caret \
omitted?  If q3_1 is 1, there is little value in also testing for missing.

I cannot guess what you want if, for example, q3_3 is 5 and q3_4 is missing.  If q3_1 \
is 1 and q3_3 is 3, this code will return 1 rather than 7--is that desired?

Just personal experience, I often end a complex sequence like this with either
else newq3=.x
or
else put _all_
or even
else abort abend 17 
Tim
-----Original Message-----
Date:    Wed, 5 Jan 2022 23:26:17 -0600
From:    greg holly <mak.hholly@GMAIL.COM>
Subject: Why these codes do not work

Hi all,
I need to create a new variable named "newq3" from 6 variables
(q3_1-q3_6).  .  If there is overlap the newq3 will be 7.  I have the
following codes but they do not work appropriately. I would be
appreciate your help to fix the codes.

Kind regards,
Greg
then
if q3_1 =. and q3_2 =. and q3_3 =. and
q3_4 =. and q3_5 =. and q3_6 =. then newq3=.;
else if q3_1=1 then newq3=1;
else if q3_2=2 then newq3=2;
else if q3_3=3 then newq3=3;
else if q3_4=4 then newq3=4;
else if q3_5=5 then newq3=5;
else if q3_6=6 then newq3=6;
else if (q3_1 =1 and q3_1 ^=.)
and (q3_2 ^=2 and q3_2 ^=.)
and (q3_3 ^=3 and q3_3 ^=.)
and (q3_4 ^=4 and q3_4 ^=.)
and (q3_5 ^=5 and q3_5 ^=.)
and (q3_6 ^=6 and q3_6 ^=.) then newq3 =7;
run;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic