<?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 Re: Multiple and Different Outcomes - Single Observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693476#M211450</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The conditions are :&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;SPAN&gt;IF Number &amp;lt;55 AND Type = "Foot"&amp;nbsp; = 1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;IF Type = "Foot" and Code = "Slow" = 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;SPAN&gt;IF Code = "Slow" = 3&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;IF Number &amp;gt; 5&amp;nbsp; = 4&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="inherit"&gt;The final result are if it hit ones of the rules or &lt;/FONT&gt;multiple&lt;FONT face="inherit"&gt;.&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="inherit"&gt;The outcome is just the name of the variable. This could be named anything as long as it is number 1 to 4.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="inherit"&gt;So an account may hit no &lt;/FONT&gt;conditions&lt;FONT face="inherit"&gt;, one condition or multiple conditions. Depending what it hits then depends what is populated in the outcome variable.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;thanks.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Oct 2020 12:23:02 GMT</pubDate>
    <dc:creator>Mick_bill</dc:creator>
    <dc:date>2020-10-22T12:23:02Z</dc:date>
    <item>
      <title>Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693460#M211443</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if someone could help me with an issue I am having.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently trying to find multiple outcomes for one observation across multiple scenarios, however i seem to be getting a repeat answer for my solution. I have seen multiple outcomes are possible i am not sure on how to get these to be outputted in one step. I believe i may have over complicated this, or it may not be possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have provided the an example code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data original;&lt;/P&gt;&lt;P&gt;input KEY $ Number Type $ Code $;&lt;/P&gt;&lt;P&gt;/*id=_n_;*/&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 5 Car Fast&lt;BR /&gt;2 100 Foot Slow&lt;BR /&gt;3 10 Bus Fast&lt;BR /&gt;4 25 Foot Medium&lt;BR /&gt;5 60 Car Slow&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA ORIGINAL2; SET ORIGINAL;&lt;BR /&gt;LENGTH OUTCOME1 OUTCOME2 OUTCOME3 OUTCOME4 $20.;&lt;/P&gt;&lt;P&gt;ARRAY OUTCOME [*] $ OUTCOME1 - OUTCOME9;&lt;/P&gt;&lt;P&gt;DO i = 1 TO 5;&lt;BR /&gt;IF OUTCOME[i] = "" THEN DO;&lt;/P&gt;&lt;P&gt;IF OUTCOME1 NE "1" OR OUTCOME2 NE "1" OR&lt;BR /&gt;OUTCOME3 NE "1" OR OUTCOME4 NE "1" THEN DO;&lt;/P&gt;&lt;P&gt;IF Number &amp;lt;55 AND Type = "Foot" THEN DO;&lt;BR /&gt;OUTCOME[i] = "1";&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;/P&gt;&lt;P&gt;IF OUTCOME[i] = "" THEN DO;&lt;/P&gt;&lt;P&gt;IF OUTCOME1 NE "2" OR OUTCOME2 NE "2" OR&lt;BR /&gt;OUTCOME3 NE "2" OR OUTCOME4 NE "2" THEN DO;&lt;/P&gt;&lt;P&gt;IF Type = "Foot" and Code = "Slow" THEN DO;&lt;BR /&gt;OUTCOME[i] = "2";&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;/P&gt;&lt;P&gt;IF OUTCOME[i] = "" THEN DO;&lt;/P&gt;&lt;P&gt;IF OUTCOME1 NE "3" OR OUTCOME2 NE "3" OR&lt;BR /&gt;OUTCOME3 NE "3" OR OUTCOME4 NE "3" THEN DO;&lt;/P&gt;&lt;P&gt;IF Code = "Slow" THEN DO;&lt;BR /&gt;OUTCOME[i] = "3";&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;/P&gt;&lt;P&gt;IF OUTCOME[i] = "" THEN DO;&lt;/P&gt;&lt;P&gt;IF OUTCOME1 NE "4" OR OUTCOME2 NE "4" OR&lt;BR /&gt;OUTCOME3 NE "4" OR OUTCOME4 NE "4" THEN DO;&lt;/P&gt;&lt;P&gt;IF Number &amp;gt; 5 THEN DO;&lt;BR /&gt;OUTCOME[i] = "4";&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will notice that the outcome repeats its self until loop 5 where this changes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My desired outcome is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Outcome;&lt;BR /&gt;input KEY $ Number Type $ Code $ OUTCOME1 $ OUTCOME2 $ OUTCOME3 $ OUTCOME4 $;&lt;/P&gt;&lt;P&gt;/*id=_n_;*/&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 5 Car Fast . . . .&lt;BR /&gt;2 100 Foot Slow 2 3 4 .&lt;BR /&gt;3 10 Bus Fast 4 . . .&lt;BR /&gt;4 25 Foot Medium 1 4 . .&lt;BR /&gt;5 60 Car Slow 3 4 . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know how to do this as i am getting confused. I have noticed that when I remove the&amp;nbsp; IF OUTCOME1 NE "4" OR OUTCOME... section this constantly repeats it as at point 5 i can see this actually changes currently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Michael&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 11:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693460#M211443</guid>
      <dc:creator>Mick_bill</dc:creator>
      <dc:date>2020-10-22T11:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693463#M211444</link>
      <description>&lt;P&gt;Please explain the rules for building your 4 result variables in plain language.&lt;/P&gt;
&lt;P&gt;Why will they all be missing in the first observation, and how are the values in the other observations determined?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 11:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693463#M211444</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-22T11:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693467#M211446</link>
      <description>&lt;P&gt;Sorry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to how many of the rules in the outcomes are being hit. So i have label them as outcome to show which one they have hit.&lt;BR /&gt;&lt;BR /&gt;The first one obs does not hit any of the outcomes as it doesn't hit any of the conditions stated. But after this we see that each observation hits at least one of the conditions.&amp;nbsp;If it hits multiple conditions I would need it state each of the conditions it has hit. The ordering would need to be which outcome was hit first at the start and then follow with the other outcomes as it goes down the conditions. So i have labelled it outcome 1 to 4 to show which of these outcomes where hit first and then which had then followed.&lt;BR /&gt;&lt;BR /&gt;Which is what outcome dataset it trying to show.&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 11:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693467#M211446</guid>
      <dc:creator>Mick_bill</dc:creator>
      <dc:date>2020-10-22T11:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693472#M211448</link>
      <description>&lt;P&gt;Please define "rules" and "outcomes". Which x must compare in which way to which y to give OUTCOME1, for instance?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 12:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693472#M211448</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-22T12:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693476#M211450</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The conditions are :&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;SPAN&gt;IF Number &amp;lt;55 AND Type = "Foot"&amp;nbsp; = 1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;IF Type = "Foot" and Code = "Slow" = 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;SPAN&gt;IF Code = "Slow" = 3&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;IF Number &amp;gt; 5&amp;nbsp; = 4&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="inherit"&gt;The final result are if it hit ones of the rules or &lt;/FONT&gt;multiple&lt;FONT face="inherit"&gt;.&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="inherit"&gt;The outcome is just the name of the variable. This could be named anything as long as it is number 1 to 4.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="inherit"&gt;So an account may hit no &lt;/FONT&gt;conditions&lt;FONT face="inherit"&gt;, one condition or multiple conditions. Depending what it hits then depends what is populated in the outcome variable.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;thanks.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 12:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693476#M211450</guid>
      <dc:creator>Mick_bill</dc:creator>
      <dc:date>2020-10-22T12:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693481#M211454</link>
      <description>&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data original2;
set original;
length cresult $4;
array outcome{*} outcome1-outcome4;
if Number &amp;lt; 55 and Type = "Foot" then cresult = "1";
if Type = "Foot" and Code = "Slow" then cresult = cats(cresult,"2");
if Code = "Slow" then cresult = cats(cresult,"3");
if Number &amp;gt; 5 then cresult = cats(cresult,"4");
do i = 1 to length(cresult);
  outcome{i} = input(substr(cresult,i,1),1.);
end;
drop cresult i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Oct 2020 12:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693481#M211454</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-22T12:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693484#M211456</link>
      <description>thanks for this. Would this be possible if the outcomes where not numbers but a character variable which is length of 4 E.g. instead of 1, 2 3 4&lt;BR /&gt;It is&lt;BR /&gt;ONE1&lt;BR /&gt;TWO2&lt;BR /&gt;THRE&lt;BR /&gt;FOUR</description>
      <pubDate>Thu, 22 Oct 2020 12:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693484#M211456</guid>
      <dc:creator>Mick_bill</dc:creator>
      <dc:date>2020-10-22T12:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693490#M211460</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data original2;
set original;
length cresult $4;
array outcome{*} $4 outcome1-outcome4;
if Number &amp;lt; 55 and Type = "Foot" then cresult = "1";
if Type = "Foot" and Code = "Slow" then cresult = cats(cresult,"2");
if Code = "Slow" then cresult = cats(cresult,"3");
if Number &amp;gt; 5 then cresult = cats(cresult,"4");
do i = 1 to length(cresult);
  select (substr(cresult,i,1));
    when ("1") outcome{i} = "ONE1";
    when ("2") outcome{i} = "TWO2";
    when ("3") outcome{i} = "THRE";
    when ("4") outcome{i} = "FOUR";
    otherwise;
  end;
end;
drop cresult i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Oct 2020 12:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693490#M211460</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-22T12:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple and Different Outcomes - Single Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693537#M211490</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132589"&gt;@Mick_bill&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The conditions are :&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;SPAN&gt;IF Number &amp;lt;55 AND Type = "Foot"&amp;nbsp; = 1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;IF Type = "Foot" and Code = "Slow" = 2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;SPAN&gt;IF Code = "Slow" = 3&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="inherit"&gt;IF Number &amp;gt; 5&amp;nbsp; = 4&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="inherit"&gt;The final result are if it hit ones of the rules or &lt;/FONT&gt;multiple&lt;FONT face="inherit"&gt;.&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="inherit"&gt;The outcome is just the name of the variable. This could be named anything as long as it is number 1 to 4.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="inherit"&gt;So an account may hit no &lt;/FONT&gt;conditions&lt;FONT face="inherit"&gt;, one condition or multiple conditions. Depending what it hits then depends what is populated in the outcome variable.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="inherit"&gt;thanks.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So what do you want when Number &amp;lt; 55 , Type='Foot' &lt;STRONG&gt;and&lt;/STRONG&gt; Code='Slow'? If you want the 1 then you need to think in terms of ELSE&lt;/P&gt;
&lt;PRE&gt;IF Number &amp;lt;55 AND Type = "Foot"  then Variable  = 1;
Else IF Type = "Foot" and Code = "Slow"  then Variable = 2;
Else IF Code = "Slow" = 3 then Variable=3;
Else IF Number &amp;gt; 5  then Variable = 4 ;&lt;/PRE&gt;
&lt;P&gt;Otherwise regardless of the value of Type or Code when Number &amp;gt; 5 you will get a result of 4.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 15:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-and-Different-Outcomes-Single-Observation/m-p/693537#M211490</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-22T15:20:30Z</dc:date>
    </item>
  </channel>
</rss>

