<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic IF satament in WHEN in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56407#M15768</link>
    <description>I am using SELECT and WHEN to check values in a loop.&lt;BR /&gt;
&lt;BR /&gt;
I am having a problem with the following code -&lt;BR /&gt;
&lt;BR /&gt;
do i=1 to 5;&lt;BR /&gt;
&lt;BR /&gt;
if Rate(i)=0 then&lt;BR /&gt;
	UnmeasVol(i) = 0;&lt;BR /&gt;
	else&lt;BR /&gt;
	select (i);&lt;BR /&gt;
		when (4)&lt;BR /&gt;
			if ExSuccVol + ExUnsuccVol + NewSuccVol + NewUnsuccVol = 0 then UnmeasVol(4) = 0;&lt;BR /&gt;
					else&lt;BR /&gt;
					UnmeasVol (4) = TotMeasWld / (ExSuccVol + ExUnsuccVol + NewSuccVol+ NewUnsuccVol) * (ExBookedConv + NewBookedConv)*Rate(i);&lt;BR /&gt;
		when (5)&lt;BR /&gt;
			UnmeasVol(5) = Ex_Reg_Meas_Workload.SL_NAO_WLD + New_Reg_Meas_Workload.SL_NAO_WLD;&lt;BR /&gt;
		Otherwise&lt;BR /&gt;
			UnmeasVol(i)=TotMeasRegWld * Rate(i);&lt;BR /&gt;
	end;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
It seems to fall down when trying to execute the code after When (4) (i=4) and is expecting WHEN, OTHERWISE or END.&lt;BR /&gt;
&lt;BR /&gt;
Not sure why.........any ides????</description>
    <pubDate>Thu, 23 Oct 2008 10:20:29 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-10-23T10:20:29Z</dc:date>
    <item>
      <title>IF satament in WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56407#M15768</link>
      <description>I am using SELECT and WHEN to check values in a loop.&lt;BR /&gt;
&lt;BR /&gt;
I am having a problem with the following code -&lt;BR /&gt;
&lt;BR /&gt;
do i=1 to 5;&lt;BR /&gt;
&lt;BR /&gt;
if Rate(i)=0 then&lt;BR /&gt;
	UnmeasVol(i) = 0;&lt;BR /&gt;
	else&lt;BR /&gt;
	select (i);&lt;BR /&gt;
		when (4)&lt;BR /&gt;
			if ExSuccVol + ExUnsuccVol + NewSuccVol + NewUnsuccVol = 0 then UnmeasVol(4) = 0;&lt;BR /&gt;
					else&lt;BR /&gt;
					UnmeasVol (4) = TotMeasWld / (ExSuccVol + ExUnsuccVol + NewSuccVol+ NewUnsuccVol) * (ExBookedConv + NewBookedConv)*Rate(i);&lt;BR /&gt;
		when (5)&lt;BR /&gt;
			UnmeasVol(5) = Ex_Reg_Meas_Workload.SL_NAO_WLD + New_Reg_Meas_Workload.SL_NAO_WLD;&lt;BR /&gt;
		Otherwise&lt;BR /&gt;
			UnmeasVol(i)=TotMeasRegWld * Rate(i);&lt;BR /&gt;
	end;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
It seems to fall down when trying to execute the code after When (4) (i=4) and is expecting WHEN, OTHERWISE or END.&lt;BR /&gt;
&lt;BR /&gt;
Not sure why.........any ides????</description>
      <pubDate>Thu, 23 Oct 2008 10:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56407#M15768</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-23T10:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: IF satament in WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56408#M15769</link>
      <description>Your syntax is wrong - try one of the 2 altenatives (must be modified for your need)&lt;BR /&gt;
&lt;B&gt;1)&lt;/B&gt;[pre]&lt;BR /&gt;
do i=1 to 5;&lt;BR /&gt;
	if Rate(i)=0 then&lt;BR /&gt;
		UnmeasVol(i) = 0;&lt;BR /&gt;
	else&lt;BR /&gt;
	select (i);&lt;BR /&gt;
		when (4)&lt;BR /&gt;
			UnmeasVol(4) = TotMeasWld / (ExSuccVol + ExUnsuccVol + NewSuccVol+ NewUnsuccVol) * (ExBookedConv + NewBookedConv)*Rate(i);&lt;BR /&gt;
		when (5)&lt;BR /&gt;
			UnmeasVol(5) = Ex_Reg_Meas_Workload.SL_NAO_WLD + New_Reg_Meas_Workload.SL_NAO_WLD;&lt;BR /&gt;
		Otherwise&lt;BR /&gt;
			UnmeasVol(i)=TotMeasRegWld * Rate(i);&lt;BR /&gt;
	end;&lt;BR /&gt;
	if ExSuccVol + ExUnsuccVol + NewSuccVol + NewUnsuccVol = 0 then UnmeasVol(4) = 0;&lt;BR /&gt;
end;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;B&gt;2)&lt;/B&gt;[pre]&lt;BR /&gt;
do i=1 to 5;&lt;BR /&gt;
	if Rate(i)=0 then&lt;BR /&gt;
		UnmeasVol(i) = 0;&lt;BR /&gt;
	else&lt;BR /&gt;
	select (i);&lt;BR /&gt;
		when (4)&lt;BR /&gt;
			do;&lt;BR /&gt;
				if ExSuccVol + ExUnsuccVol + NewSuccVol + NewUnsuccVol = 0 then UnmeasVol(4) = 0;&lt;BR /&gt;
				else&lt;BR /&gt;
				UnmeasVol (4) = TotMeasWld / (ExSuccVol + ExUnsuccVol + NewSuccVol+ NewUnsuccVol) * (ExBookedConv + NewBookedConv)*Rate(i);&lt;BR /&gt;
			end;&lt;BR /&gt;
		when (5)&lt;BR /&gt;
			UnmeasVol(5) = Ex_Reg_Meas_Workload.SL_NAO_WLD + New_Reg_Meas_Workload.SL_NAO_WLD;&lt;BR /&gt;
		Otherwise&lt;BR /&gt;
			UnmeasVol(i)=TotMeasRegWld * Rate(i);&lt;BR /&gt;
	end;&lt;BR /&gt;
end;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
More info at &lt;A href="http://support.sas.com/onlinedoc/913/getDoc/da/lrdict.hlp/a000201966.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/da/lrdict.hlp/a000201966.htm&lt;/A&gt;</description>
      <pubDate>Thu, 23 Oct 2008 11:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56408#M15769</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2008-10-23T11:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: IF satament in WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56409#M15770</link>
      <description>Ok, that makes sense, but it does seem strange that you can't perform an IF statement within a SELECT WHEN statement?&lt;BR /&gt;
&lt;BR /&gt;
Is there any other way of performing such a function within a SELECT WHEN statement as I can forsee me having problems in future if I can't do this?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the code though &lt;span class="lia-unicode-emoji" title=":monkey_face:"&gt;🐵&lt;/span&gt;</description>
      <pubDate>Thu, 23 Oct 2008 11:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56409#M15770</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-23T11:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: IF satament in WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56410#M15771</link>
      <description>You can use IF within as SELECT statement - Look at &lt;A href="http://support.sas.com/onlinedoc/913/getDoc/da/lrdict.hlp/a000201966.htm#a000202177" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/da/lrdict.hlp/a000201966.htm#a000202177&lt;/A&gt; or my example 2) above.&lt;BR /&gt;
&lt;BR /&gt;
Your problem is not the IF statement, but the fact that your are using more than 1 line of code within the WHEN statement. You must use DO/END structure, to write more statements i.e. IF/THEN/ELSE.</description>
      <pubDate>Thu, 23 Oct 2008 12:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-satament-in-WHEN/m-p/56410#M15771</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2008-10-23T12:38:56Z</dc:date>
    </item>
  </channel>
</rss>

