<?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-then in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399017#M96587</link>
    <description>&lt;P&gt;Given the raw data file EMPLOYEE:&lt;/P&gt;&lt;P&gt;----I----1 0---I----20---I----30&lt;BR /&gt;Ruth 39 11&lt;BR /&gt;Jose 32 22&lt;BR /&gt;Sue 30 33&lt;BR /&gt;John 40 44&lt;BR /&gt;The following SAS program is submitted:&lt;BR /&gt;data test;&lt;BR /&gt;infile ‘employee’;&lt;BR /&gt;input employee_name $ 1-4;&lt;BR /&gt;if employee_name = ‘Ruth’ then input idnum 10-11;&lt;BR /&gt;else input age 7-8;&lt;BR /&gt;run;&lt;BR /&gt;What value does the variable IDNUM contain when the name of the employee is “Ruth”?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ans is 22? I do not understand why. Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2017 03:54:03 GMT</pubDate>
    <dc:creator>pchen002</dc:creator>
    <dc:date>2017-09-27T03:54:03Z</dc:date>
    <item>
      <title>if-then</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399017#M96587</link>
      <description>&lt;P&gt;Given the raw data file EMPLOYEE:&lt;/P&gt;&lt;P&gt;----I----1 0---I----20---I----30&lt;BR /&gt;Ruth 39 11&lt;BR /&gt;Jose 32 22&lt;BR /&gt;Sue 30 33&lt;BR /&gt;John 40 44&lt;BR /&gt;The following SAS program is submitted:&lt;BR /&gt;data test;&lt;BR /&gt;infile ‘employee’;&lt;BR /&gt;input employee_name $ 1-4;&lt;BR /&gt;if employee_name = ‘Ruth’ then input idnum 10-11;&lt;BR /&gt;else input age 7-8;&lt;BR /&gt;run;&lt;BR /&gt;What value does the variable IDNUM contain when the name of the employee is “Ruth”?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ans is 22? I do not understand why. Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 03:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399017#M96587</guid>
      <dc:creator>pchen002</dc:creator>
      <dc:date>2017-09-27T03:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399019#M96588</link>
      <description>&lt;P&gt;&amp;nbsp;No trailing @.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each INPUT statement reads from a new line by default. To keep it on the same line you need the trailing&amp;nbsp;@.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 04:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399019#M96588</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-27T04:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399041#M96597</link>
      <description>&lt;P&gt;Sorry I still don't quite get it, still a noobie for SAS!!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 06:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399041#M96597</guid>
      <dc:creator>pchen002</dc:creator>
      <dc:date>2017-09-27T06:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399054#M96606</link>
      <description>&lt;P&gt;Compare next code to the one you used:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile ‘employee’;
input employee_name $ 1-4  @;    /* &amp;lt;&amp;lt;&amp;lt;&amp;lt; @ added &amp;lt;&amp;lt;&amp;lt; */
if employee_name = ‘Ruth’ then input idnum 10-11;
else input age 7-8;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You got 22 taken from next row.&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;@ character makes sas stay on current row up to next INPUT ...; staement (without&amp;nbsp;@).&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 07:30:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399054#M96606</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-09-27T07:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399063#M96612</link>
      <description>I understand the @ part already, but where do they start reading the data for idnum 10-11(not sure which column they read to result the observation=22)?</description>
      <pubDate>Wed, 27 Sep 2017 08:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399063#M96612</guid>
      <dc:creator>pchen002</dc:creator>
      <dc:date>2017-09-27T08:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399064#M96613</link>
      <description>SAS reads from the columns you specified in&lt;BR /&gt;"then input idnum 10-11;"&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Sep 2017 08:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399064#M96613</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-09-27T08:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399065#M96614</link>
      <description>&lt;P&gt;Having the code: "INPUT IDNUM 10-11;" means get idnum from positions 10-11.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having "INPUT NAME 1-4&amp;nbsp;@";&amp;nbsp; &amp;nbsp;you stay on current row with name=RUTH.&lt;/P&gt;
&lt;P&gt;Without the @ character, sas skips to the next row where name=JOSE then&lt;/P&gt;
&lt;P&gt;reads positions 10-11 with idnum=22;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 08:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399065#M96614</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-09-27T08:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399085#M96617</link>
      <description>Understood!thanks!!</description>
      <pubDate>Wed, 27 Sep 2017 09:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then/m-p/399085#M96617</guid>
      <dc:creator>pchen002</dc:creator>
      <dc:date>2017-09-27T09:37:32Z</dc:date>
    </item>
  </channel>
</rss>

