<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi All,</p>
<p style="margin-top:0;margin-bottom:0"> This isn't an important question, but it's an issue that's cropped up for me enough to count on two hands now. Basically, I'd love to use the "where" function to return values that are not of the same type as the conditional
expression. I'm just wondering if anyone has an elegant way around this that doesn't involve a do loop and if check. </p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">This often gives an error, as the documentation notes ("<span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px;">If neither type can be coerced to the other type, an error is returned</span>"). </p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Here's a standard example of why I'd like to use it this way. Say I'm making a risk table for various weather phenomena contingent on that phenomena's value (like say, wind speed or rainfall).</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">It'd be really nice/easy to be able to do something like:</p>
<p style="margin-top:0;margin-bottom:0">----------------</p>
<p style="margin-top:0;margin-bottom:0">; note: below two arrays have same size</p>
<p style="margin-top:0;margin-bottom:0">riskvalues = *series of random numbers for a variable, say precipitation in inches*</p>
<p style="margin-top:0;margin-bottom:0">riskwords = *series of words - begin with all equal to "None"*</p>
<p style="margin-top:0;margin-bottom:0">riskwords = where(riskvalues.gt.1,"High",<span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">riskwords)
; assigns a high risk when precipitation is large</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">--------------</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">This will give
an error because you're returning a string, which can't be coerced to the number type you're evaluating. </span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">So my question is twofold - (1) is there a way/flag to negate this behavior? and (2) assuming not, does anyone have a more elegant solution than a nested assignment inside an if check inside a do loop? It seems like the
point of where is to avoid this situation.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Thanks for any input!</p>
<p style="margin-top:0;margin-bottom:0"> - lazy coder</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">Nick Bassill, PhD</span></p>
<p style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">
Modeler & Meteorologist, Center Of Excellence (Prior: NYS Mesonet)</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">
LC SB-28, 1400 Washington Ave.,</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">
SUNY, University at Albany, NY 12222</p>
(518) 442-6375</div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
NYSM Products: <a href="http://operations.nysmesonet.org/~nbassill/" class="OWAAutoLink" id="LPNoLP">http://operations.nysmesonet.org/~nbassill/</a></div>
</div>
</div>
</div>
</body>
</html>