<?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: quasi-complex if-then structures in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608817#M177216</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/273054"&gt;@emaguin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Long time spss user. I want to see what the sas equivalent is for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do if (x eq 1 and y eq 3).&lt;/P&gt;
&lt;P&gt;compute a=2.&lt;/P&gt;
&lt;P&gt;compute b=3.&lt;/P&gt;
&lt;P&gt;compute c=7.&lt;/P&gt;
&lt;P&gt;else if (x eq 2 and y eq 4).&lt;/P&gt;
&lt;P&gt;compute a=1.&lt;/P&gt;
&lt;P&gt;compute b=0.&lt;/P&gt;
&lt;P&gt;compute c=4.&lt;/P&gt;
&lt;P&gt;else.&lt;/P&gt;
&lt;P&gt;compute a=4.&lt;/P&gt;
&lt;P&gt;compute b=5.&lt;/P&gt;
&lt;P&gt;compute c=9.&lt;/P&gt;
&lt;P&gt;end if.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or do if have to do this three times, subbing in b and c for a?&lt;/P&gt;
&lt;P&gt;if (x eq 1 and y eq 3) then compute a=2;&lt;/P&gt;
&lt;P&gt;else if (x eq 2 and y eq 4) then compute a=1;&lt;/P&gt;
&lt;P&gt;else then compute a=4;&amp;nbsp; /* this line may not be correct */;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks, Gene Maguin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;if (x eq 1 and y eq 3) then do;
   a=2;
   b=3;
   c=7;
end;
else if (x eq 2 and y eq 4) then do;
   a=1;
   b=0;
   c=4;
end;
else do;
   a=4;
   b=5;
   c=9;
end ;
&lt;/PRE&gt;
&lt;P&gt;Please post code or log entries into a code box opened using the forum's {I} icon to preserve formatting and to prevent the forum from inserting additional new line characters.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2019 18:58:56 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-12-02T18:58:56Z</dc:date>
    <item>
      <title>quasi-complex if-then structures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608814#M177214</link>
      <description>&lt;P&gt;Long time spss user. I want to see what the sas equivalent is for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do if (x eq 1 and y eq 3).&lt;/P&gt;&lt;P&gt;compute a=2.&lt;/P&gt;&lt;P&gt;compute b=3.&lt;/P&gt;&lt;P&gt;compute c=7.&lt;/P&gt;&lt;P&gt;else if (x eq 2 and y eq 4).&lt;/P&gt;&lt;P&gt;compute a=1.&lt;/P&gt;&lt;P&gt;compute b=0.&lt;/P&gt;&lt;P&gt;compute c=4.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;compute a=4.&lt;/P&gt;&lt;P&gt;compute b=5.&lt;/P&gt;&lt;P&gt;compute c=9.&lt;/P&gt;&lt;P&gt;end if.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or do if have to do this three times, subbing in b and c for a?&lt;/P&gt;&lt;P&gt;if (x eq 1 and y eq 3) then compute a=2;&lt;/P&gt;&lt;P&gt;else if (x eq 2 and y eq 4) then compute a=1;&lt;/P&gt;&lt;P&gt;else then compute a=4;&amp;nbsp; /* this line may not be correct */;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Gene Maguin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 18:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608814#M177214</guid>
      <dc:creator>emaguin</dc:creator>
      <dc:date>2019-12-02T18:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: quasi-complex if-then structures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608817#M177216</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/273054"&gt;@emaguin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Long time spss user. I want to see what the sas equivalent is for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do if (x eq 1 and y eq 3).&lt;/P&gt;
&lt;P&gt;compute a=2.&lt;/P&gt;
&lt;P&gt;compute b=3.&lt;/P&gt;
&lt;P&gt;compute c=7.&lt;/P&gt;
&lt;P&gt;else if (x eq 2 and y eq 4).&lt;/P&gt;
&lt;P&gt;compute a=1.&lt;/P&gt;
&lt;P&gt;compute b=0.&lt;/P&gt;
&lt;P&gt;compute c=4.&lt;/P&gt;
&lt;P&gt;else.&lt;/P&gt;
&lt;P&gt;compute a=4.&lt;/P&gt;
&lt;P&gt;compute b=5.&lt;/P&gt;
&lt;P&gt;compute c=9.&lt;/P&gt;
&lt;P&gt;end if.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or do if have to do this three times, subbing in b and c for a?&lt;/P&gt;
&lt;P&gt;if (x eq 1 and y eq 3) then compute a=2;&lt;/P&gt;
&lt;P&gt;else if (x eq 2 and y eq 4) then compute a=1;&lt;/P&gt;
&lt;P&gt;else then compute a=4;&amp;nbsp; /* this line may not be correct */;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks, Gene Maguin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;if (x eq 1 and y eq 3) then do;
   a=2;
   b=3;
   c=7;
end;
else if (x eq 2 and y eq 4) then do;
   a=1;
   b=0;
   c=4;
end;
else do;
   a=4;
   b=5;
   c=9;
end ;
&lt;/PRE&gt;
&lt;P&gt;Please post code or log entries into a code box opened using the forum's {I} icon to preserve formatting and to prevent the forum from inserting additional new line characters.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 18:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608817#M177216</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-02T18:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: quasi-complex if-then structures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608818#M177217</link>
      <description>&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data foo;
	x=1;
	y=3;

	if (x eq 1 and y eq 3) then
		do;
			a=2;
			b=3;
			c=7;
		end;
	else if (x eq 2 and y eq 4) then
		do;
			a=1;
			b=0;
			c=4;
		end;
	else
		do;
			a=4;
			b=5;
			c=9;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 Dec 2019 18:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608818#M177217</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-12-02T18:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: quasi-complex if-then structures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608819#M177218</link>
      <description>&lt;P&gt;I don't know about SPSS, by SAS syntax is fully described and explained in the documentation. You could start here, for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=basess&amp;amp;docsetTarget=p1n2fl39v0v2ffn1m3vm4a9kz2e5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;https://documentation.sas.com/?docsetId=basess&amp;amp;docsetTarget=p1n2fl39v0v2ffn1m3vm4a9kz2e5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 19:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608819#M177218</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-12-02T19:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: quasi-complex if-then structures</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608831#M177227</link>
      <description>&lt;P&gt;If a SELECT-WHEN (or CASE-WHEN in SQL) is more in line with your mental model, &lt;A href="https://blogs.sas.com/content/iml/2016/06/20/select-when-sas-data-step.html" target="_self"&gt;you can use SELECT-WHEN-OTHERWISE&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data in;
  x=1;  y=3;
  output;
  x=2;  y=4;
  output;
  x=0;  y=0;
  output;
run;

data foo;
  set in;
  select;
   when (x eq 1 and y eq 3) 
    do;
      a=2; b=3; c=7;
    end;
   when (x eq 2 and y eq 4)
    do;
      a=1; b=0; c=4;
    end;
  otherwise
    do;
      a=4; b=5; c=9;
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2019 19:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quasi-complex-if-then-structures/m-p/608831#M177227</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2019-12-02T19:46:03Z</dc:date>
    </item>
  </channel>
</rss>

