[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: Re: Why these codes do not work
From: Mark Keintz <mkeintz () OUTLOOK ! COM>
Date: 2022-01-07 0:39:58
Message-ID: BL0PR10MB28040D9E27BCC3A3D0F40AB5B64D9 () BL0PR10MB2804 ! namprd10 ! prod ! outlook ! com
[Download RAW message or body]
[Attachment #2 (text/plain)]
Greg:
Even after reading Joe's and Nat's responses to your post, I don't understand what \
results you want.
First of all, I don't know what you mean by "if there is overlap"
Otherwise it looks to me like
1. If all Q3_'s are missing then so is newq3
2. Else newq3 is set equal to the first Q3_ variable whose value matches the \
last digit of its name
3. Else newq3 is a 7 if none of the variables is missing and none of them have \
a value matching the last digit of its name.
But this understanding would mean that no value is determined for NEWQ3 if at least \
one of the variables is missing and none of the others have values matching \
last-digit-of-name. For instance NEWQ3 would no assigned value for Q3_1=2, Q3_2=3, \
Q3‑3=4, Q3_4=5, Q3_5=6 and Q3_6=.
Mark
From: SAS(r) Discussion <SAS-L@LISTSERV.UGA.EDU> On Behalf Of greg holly
Sent: Thursday, January 6, 2022 12:26 AM
To: SAS-L@LISTSERV.UGA.EDU
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;
[Attachment #3 (text/html)]
<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:2040930048;
mso-list-type:hybrid;
mso-list-template-ids:-19994118 67698703 67698713 67698715 67698703 67698713 \
67698715 67698703 67698713 67698715;} @list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Greg:<o:p></o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Even \
after reading Joe's and Nat's responses to your post, I don't understand what results \
you want. <o:p></o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">First \
of all, I don't know what you mean by "if there is overlap"<o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Otherwise \
it looks to me like<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if \
!supportLists]><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><span \
style="mso-list:Ignore">1.<span style="font:7.0pt "Times New \
Roman""> \
</span></span></span><![endif]><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">If \
all Q3_'s are missing then so is newq3<br> <br>
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if \
!supportLists]><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><span \
style="mso-list:Ignore">2.<span style="font:7.0pt "Times New \
Roman""> \
</span></span></span><![endif]><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Else \
newq3 is set equal to the first Q3_ variable whose value matches the last digit of \
its name<br> <br>
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if \
!supportLists]><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><span \
style="mso-list:Ignore">3.<span style="font:7.0pt "Times New \
Roman""> \
</span></span></span><![endif]><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Else \
newq3 is a 7 if none of the variables is missing and none of them have a value \
matching the last digit of its name.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal">But this understanding would mean that no value is determined \
for NEWQ3 if at least one of the variables is missing and none of the others have \
values matching last-digit-of-name. For instance NEWQ3 would no assigned value \
for<o:p></o:p></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> \
Q3_1=2, Q3_2=3, Q3‑3=4, Q3_4=5, Q3_5=6 and Q3_6=.<o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Mark<o:p></o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span \
style="font-size:11.0pt;font-family:"Calibri",sans-serif"> SAS(r) \
Discussion <SAS-L@LISTSERV.UGA.EDU> <b>On Behalf Of </b>greg holly<br>
<b>Sent:</b> Thursday, January 6, 2022 12:26 AM<br>
<b>To:</b> SAS-L@LISTSERV.UGA.EDU<br>
<b>Subject:</b> Why these codes do not work<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<div>
<p class="MsoNormal">I need to create a new variable named "newq3" from 6 \
variables (q3_1-q3_6). <span \
style="font-family:"Calibri",sans-serif">. 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.</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">Kind \
regards,</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span \
style="font-family:"Calibri",sans-serif">Greg</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span \
style="font-family:"Calibri",sans-serif">then </span><o:p></o:p></p> \
<div> <p class="MsoNormal">if q3_1 =. and q3_2 =. and q3_3 =. and<br>
q3_4 =. and q3_5 =. and q3_6 =. then newq3=.;<br>
else if q3_1=1 then newq3=1;<br>
else if q3_2=2 then newq3=2;<br>
else if q3_3=3 then newq3=3;<br>
else if q3_4=4 then newq3=4;<br>
else if q3_5=5 then newq3=5;<br>
else if q3_6=6 then newq3=6;<br>
else if (q3_1 =1 and q3_1 ^=.)<br>
and (q3_2 ^=2 and q3_2 ^=.)<br>
and (q3_3 ^=3 and q3_3 ^=.)<br>
and (q3_4 ^=4 and q3_4 ^=.)<br>
and (q3_5 ^=5 and q3_5 ^=.)<br>
and (q3_6 ^=6 and q3_6 ^=.) then newq3 =7;<br>
run;<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic