<?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: SAS acting weird when reading data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256062#M49020</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, SAS isn't acting wierd. &amp;nbsp;In your first example:&lt;/P&gt;
&lt;PRE&gt;input name $ age Salary comma7. test1 2. test2 2. test3 2. test4 2.;&lt;/PRE&gt;
&lt;P&gt;This is reading formatted input, so it reads the first string up to the space, then it reads the comma7 value. &amp;nbsp;But then for each of the subsequent test variables you are moving the pointer:&lt;/P&gt;
&lt;P&gt;100,000 &amp;nbsp;10 11 12 13&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;^&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pointer is here after comma read&lt;/P&gt;
&lt;P&gt;So, the test1 2. statment tells SAS to read two characters from where the pointer is, this is " 1", and conert that to number. &amp;nbsp;The pointer is then:&lt;/P&gt;
&lt;P&gt;100,000 &amp;nbsp;10 11 12 13&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ^&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pointer is here after test1 read&lt;/P&gt;
&lt;P&gt;So the next statement test2 2., reads two characters "0 " from the line. &amp;nbsp;And so on. &amp;nbsp;Hence your first example output is incorrect. &amp;nbsp;Each input statement using formatted input would need to have 3. i.e. read the space, and the two decimals, and convert to number. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the commented out code the 2. is only applied to the last test = test4, hence works correctly as test1 takes the string " 10", test2 " 11" etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Mar 2016 10:46:11 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-03-11T10:46:11Z</dc:date>
    <item>
      <title>SAS acting weird when reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256049#M49016</link>
      <description>&lt;P&gt;I am a beginner and I was trying input styles for practice. I wrote the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
/*	input name $ age Salary comma7. test1-test4 2.;*/
	input name $ age Salary comma7. test1 2. test2 2. test3 2. test4 2.;
    datalines;
abc 15 100,000 10 11 12 13
xyz 16 120,000 13 11 12 12
        ;
run;
proc print data = test;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As expected, i get the following code&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2282i23BB173C075BBC07/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Result1" title="Result1" /&gt;&lt;/P&gt;&lt;P&gt;However, on running the code using the second input statement (which is commented out in the code), I get the following result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2283i38CEF63F8A0FDE8D/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Result2.JPG" title="Result2.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As per my knowledge, both the input statements must be synonymous, then how can they give different results?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SAS version I'm using is 9.2. Can anybody throw some light on why SAS is acting so weird.&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>Fri, 11 Mar 2016 09:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256049#M49016</guid>
      <dc:creator>karan51290</dc:creator>
      <dc:date>2016-03-11T09:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS acting weird when reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256062#M49020</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, SAS isn't acting wierd. &amp;nbsp;In your first example:&lt;/P&gt;
&lt;PRE&gt;input name $ age Salary comma7. test1 2. test2 2. test3 2. test4 2.;&lt;/PRE&gt;
&lt;P&gt;This is reading formatted input, so it reads the first string up to the space, then it reads the comma7 value. &amp;nbsp;But then for each of the subsequent test variables you are moving the pointer:&lt;/P&gt;
&lt;P&gt;100,000 &amp;nbsp;10 11 12 13&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;^&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pointer is here after comma read&lt;/P&gt;
&lt;P&gt;So, the test1 2. statment tells SAS to read two characters from where the pointer is, this is " 1", and conert that to number. &amp;nbsp;The pointer is then:&lt;/P&gt;
&lt;P&gt;100,000 &amp;nbsp;10 11 12 13&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ^&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pointer is here after test1 read&lt;/P&gt;
&lt;P&gt;So the next statement test2 2., reads two characters "0 " from the line. &amp;nbsp;And so on. &amp;nbsp;Hence your first example output is incorrect. &amp;nbsp;Each input statement using formatted input would need to have 3. i.e. read the space, and the two decimals, and convert to number. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the commented out code the 2. is only applied to the last test = test4, hence works correctly as test1 takes the string " 10", test2 " 11" etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2016 10:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256062#M49020</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-11T10:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS acting weird when reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256075#M49021</link>
      <description>ohh. Thanks for the clarification. Another quick question: How do I apply informats to all the variables when using range notation (test1-test4)?</description>
      <pubDate>Fri, 11 Mar 2016 11:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256075#M49021</guid>
      <dc:creator>karan51290</dc:creator>
      <dc:date>2016-03-11T11:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS acting weird when reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256077#M49022</link>
      <description>&lt;P&gt;I am not able to test right now but:&lt;/P&gt;
&lt;PRE&gt;informat test1-test4 &amp;lt;format&amp;gt;;
&lt;/PRE&gt;
&lt;P&gt;should work so long, it will use the informat on all variables which appear in sequence left to right from test1 to test4. &amp;nbsp;If the ones you want are not in order, but they all use the same prefix then:&lt;/P&gt;
&lt;PRE&gt;informat test: &amp;lt;format&amp;gt;;&lt;/PRE&gt;
&lt;P&gt;Otherwise you need to specify each one.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2016 11:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256077#M49022</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-11T11:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS acting weird when reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256079#M49023</link>
      <description>&lt;P&gt;I just found out after a bit of googling, the correct way to assign same informats to all variables is&amp;nbsp;like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input (score1-score5) (4. 4. 4. 4. 4.);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;or a shorter form would be:&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;input (score1-score5) (4.);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;CODE class=" language-sas"&gt;&lt;CODE class=" language-sas"&gt;Additional information is here:&lt;/CODE&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;CODE class=" language-sas"&gt;&lt;CODE class=" language-sas"&gt;&lt;CODE class=" language-sas"&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000148073.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000148073.htm&lt;/A&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;I tried testing it and it works as expected.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;CODE class=" language-sas"&gt;&lt;CODE class=" language-sas"&gt;&lt;CODE class=" language-sas"&gt;Again, thank you for pointing me to right direction :)&lt;/CODE&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2016 11:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-acting-weird-when-reading-data/m-p/256079#M49023</guid>
      <dc:creator>karan51290</dc:creator>
      <dc:date>2016-03-11T11:45:16Z</dc:date>
    </item>
  </channel>
</rss>

