<?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: Easy way to do IF X = 1 2 3 or 4 THEN Y = 0 in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753906#M29927</link>
    <description>&lt;P&gt;To repeat the same logic across multiple variables use an array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array list arv1_d1 arv1_d2 arv1_d3 arv2_d1 ;
arvtype=.;
do index=1 to dim(list) until (arvtype=2);
  IF list[index] in (3,4,5,11,14,42,44,45) then arvtype = 2;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 13 Jul 2021 19:53:54 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-07-13T19:53:54Z</dc:date>
    <item>
      <title>Easy way to do IF X = 1 2 3 or 4 THEN Y = 0</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753889#M29922</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Was wondering if there was a less tedious way to write my below code: Essentially I am trying to say that if the anti retroviral therapy they have is type 3, 4, 5, etc the they are using a combination ART (ie. 2). What I have below works, but is there an easier way to write this out?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA dtanl.hivcancerdta;&lt;BR /&gt;set dtanl.hivcancerdta;&lt;BR /&gt;IF arv1_d1 = . THEN arvtype = .;&lt;BR /&gt;ELSE IF arv1_d1 = 3 THEN arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d1 = 4 THEN arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d1 = 5 THEN arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d1 = 11 THEN arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d1 = 14 THEN arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d1 = 42 THEN arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d1 = 44 THEN arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d1 = 45 THEN arvtype = 2;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 19:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753889#M29922</guid>
      <dc:creator>pramenon1</dc:creator>
      <dc:date>2021-07-13T19:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Easy way to do IF X = 1 2 3 or 4 THEN Y = 0</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753890#M29923</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA dtanl.hivcancerdta;
set dtanl.hivcancerdta;
IF arv1_d1 = . THEN arvtype = .;
ELSE IF arv1_d1 in (3,4,5,11,14,42,44,45) then arvtype = 2;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jul 2021 19:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753890#M29923</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-13T19:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Easy way to do IF X = 1 2 3 or 4 THEN Y = 0</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753892#M29924</link>
      <description>&lt;P&gt;Use the IN operator instead of the = operator.&lt;/P&gt;
&lt;P&gt;For consecutive integers you can even use the min:max syntax.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF arv1_d1 = . THEN arvtype = .;
ELSE IF arv1_d1 in (3:5 11 14 42 44 45) THEN arvtype = 2;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jul 2021 19:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753892#M29924</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-13T19:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Easy way to do IF X = 1 2 3 or 4 THEN Y = 0</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753904#M29926</link>
      <description>Quick follow up, along with arv1_d1, i also have arv1_d2 and arv1_d3. Is there a way to make this same condition apply to arv1_d2 and arv1_d3 etc?&lt;BR /&gt;&lt;BR /&gt;Below is the long way but is there a shorter way?&lt;BR /&gt;&lt;BR /&gt;ELSE IF arv1_d1 in (3,4,5,11,14,42,44,45) then arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d2 in (3,4,5,11,14,42,44,45) then arvtype = 2;&lt;BR /&gt;ELSE IF arv1_d3 in (3,4,5,11,14,42,44,45) then arvtype = 2;&lt;BR /&gt;ELSE IF arv2_d1 in (3,4,5,11,14,42,44,45) then arvtype = 2;</description>
      <pubDate>Tue, 13 Jul 2021 19:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753904#M29926</guid>
      <dc:creator>pramenon1</dc:creator>
      <dc:date>2021-07-13T19:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Easy way to do IF X = 1 2 3 or 4 THEN Y = 0</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753906#M29927</link>
      <description>&lt;P&gt;To repeat the same logic across multiple variables use an array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array list arv1_d1 arv1_d2 arv1_d3 arv2_d1 ;
arvtype=.;
do index=1 to dim(list) until (arvtype=2);
  IF list[index] in (3,4,5,11,14,42,44,45) then arvtype = 2;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jul 2021 19:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Easy-way-to-do-IF-X-1-2-3-or-4-THEN-Y-0/m-p/753906#M29927</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-13T19:53:54Z</dc:date>
    </item>
  </channel>
</rss>

