<?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: INPUT statement inside IF statement in SAS Data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INPUT-statement-inside-IF-statement-in-SAS-Data-step/m-p/318256#M69712</link>
    <description>Thank you sir! That was a very nice explanation.</description>
    <pubDate>Mon, 12 Dec 2016 12:51:51 GMT</pubDate>
    <dc:creator>PoojaP1</dc:creator>
    <dc:date>2016-12-12T12:51:51Z</dc:date>
    <item>
      <title>INPUT statement inside IF statement in SAS Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INPUT-statement-inside-IF-statement-in-SAS-Data-step/m-p/318245#M69707</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone please explain how SAS processes the following code :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Raw data file (Text file) data :&lt;/P&gt;&lt;P&gt;Ruth &amp;nbsp;39 11 (39 starts at Col7 and 11 at Col10)&lt;/P&gt;&lt;P&gt;Jose &amp;nbsp;32 22&lt;/P&gt;&lt;P&gt;Sue &amp;nbsp; 30 33&lt;/P&gt;&lt;P&gt;John 40 44&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA STEP :-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new_1;&lt;BR /&gt;infile 'test1.txt';&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;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OUTPUT :-&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;employee_name=Ruth idnum=22 age=. _ERROR_=0 _N_=1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;employee_name=Sue idnum=. age=40 _ERROR_=0 _N_=2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NOTE: The data set WORK.new_1 has 2 observations and 3 variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am not able to understand why SAS did not give output for Jose and John.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 11:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INPUT-statement-inside-IF-statement-in-SAS-Data-step/m-p/318245#M69707</guid>
      <dc:creator>PoojaP1</dc:creator>
      <dc:date>2016-12-12T11:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: INPUT statement inside IF statement in SAS Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INPUT-statement-inside-IF-statement-in-SAS-Data-step/m-p/318247#M69708</link>
      <description>&lt;P&gt;Each INPUT statement, when it closed by semicolon (;), reads one line and is ready to read the following one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to stay on same line and read more variables from it, you end the read statemnet by: &amp;nbsp;@; &amp;nbsp;like next code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;infile datalines;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;input employee_name $&amp;nbsp;&lt;STRONG&gt;@;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if employee_name = 'Ruth'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;then&amp;nbsp;&lt;SPAN&gt;input idnum 10-11;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else input age 7-8;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;Ruth &amp;nbsp;39 11&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jose &amp;nbsp;32 22&lt;/P&gt;
&lt;P&gt;Sue &amp;nbsp; 30 33&lt;/P&gt;
&lt;P&gt;John 40 44&lt;/P&gt;
&lt;P&gt;; run;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 11:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INPUT-statement-inside-IF-statement-in-SAS-Data-step/m-p/318247#M69708</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-12T11:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: INPUT statement inside IF statement in SAS Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INPUT-statement-inside-IF-statement-in-SAS-Data-step/m-p/318256#M69712</link>
      <description>Thank you sir! That was a very nice explanation.</description>
      <pubDate>Mon, 12 Dec 2016 12:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INPUT-statement-inside-IF-statement-in-SAS-Data-step/m-p/318256#M69712</guid>
      <dc:creator>PoojaP1</dc:creator>
      <dc:date>2016-12-12T12:51:51Z</dc:date>
    </item>
  </channel>
</rss>

