<?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: Length Statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244064#M56002</link>
    <description>&lt;P&gt;I support&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49185"&gt;@mohamed_zaki﻿&lt;/a&gt;'s advice to put the LENGTH statement before the INPUT statement. However, I don't think that SAS looks at the data values when it determines the lengths. Apparently, it assigns the default length to&amp;nbsp;all&amp;nbsp;character variables (marked with the dollar sign) found in the INPUT statement, i.e. $8, regardless of the actual lengths of the data values. Interestingly, SAS is flexible enough to adjust the length of &lt;EM&gt;numeric&lt;/EM&gt; variables from the default 8 to, say, 4 (bytes) if this length is specified in the LENGTH statement after the INPUT statement, without complaints in the log.&lt;/P&gt;</description>
    <pubDate>Sun, 17 Jan 2016 16:19:59 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-01-17T16:19:59Z</dc:date>
    <item>
      <title>Length Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244056#M55999</link>
      <description>&lt;P&gt;data state1;&lt;BR /&gt;input name $ rank status $ ;&lt;BR /&gt;length name $5 status $50;&lt;BR /&gt;datalines;&lt;BR /&gt;mekelele 1 nohope&lt;BR /&gt;torres 1 depress&lt;BR /&gt;valdes 1 sotkaal&lt;BR /&gt;bhutia 1 fulltension&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above statement - I have particularly set the length of variable name to $5 and status to $50&lt;/P&gt;&lt;P&gt;By that logic I must get:&lt;/P&gt;&lt;P&gt;for mekelele - makel(only 5 characters) and for fulltension - fulltension (since length is $50 the whole word must come)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, i am &amp;nbsp;not gettign the desired outcome (see screenshot attached)?&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12201iC81AB8A3F4E0207E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Length Statement Doubt.PNG" title="Length Statement Doubt.PNG" /&gt;</description>
      <pubDate>Sun, 17 Jan 2016 11:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244056#M55999</guid>
      <dc:creator>bgs</dc:creator>
      <dc:date>2016-01-17T11:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Length Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244058#M56000</link>
      <description>&lt;P&gt;&lt;STRIKE&gt;Because the INPUT&amp;nbsp;statment will figure out variables&amp;nbsp;length based on some observation automatically.&lt;/STRIKE&gt; If you want the LENGTH&amp;nbsp;statment to have effect let it be before the INPUT statment.&lt;/P&gt;
&lt;P&gt;As&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data state1;
length name $5 status $50;
input name $ rank status $ ;
datalines;
mekelele 1 nohope
torres 1 depress
valdes 1 sotkaal
bhutia 1 fulltension
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you checked your log you will figure out that easily by reading the WARNINGs you got&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: Length of character variable name has already been set. 
          Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
WARNING: Length of character variable status has already been set. 
          Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 02:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244058#M56000</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-18T02:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Length Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244064#M56002</link>
      <description>&lt;P&gt;I support&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49185"&gt;@mohamed_zaki﻿&lt;/a&gt;'s advice to put the LENGTH statement before the INPUT statement. However, I don't think that SAS looks at the data values when it determines the lengths. Apparently, it assigns the default length to&amp;nbsp;all&amp;nbsp;character variables (marked with the dollar sign) found in the INPUT statement, i.e. $8, regardless of the actual lengths of the data values. Interestingly, SAS is flexible enough to adjust the length of &lt;EM&gt;numeric&lt;/EM&gt; variables from the default 8 to, say, 4 (bytes) if this length is specified in the LENGTH statement after the INPUT statement, without complaints in the log.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jan 2016 16:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244064#M56002</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-17T16:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Length Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244121#M56008</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data state1;
input name : $5. rank status : $50. ;
datalines;
mekelele 1 nohope
torres 1 depress
valdes 1 sotkaal
bhutia 1 fulltension
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 01:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244121#M56008</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-18T01:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Length Statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244122#M56009</link>
      <description>&lt;P&gt;SAS will define the variable type and length at the first place that it sees the variable. So if that is when you reference an existing data set then the variable will take the attributes it has in that data set. &amp;nbsp;If the first place is in an INPUT statement then it will attempt to use the format used to define the type and length. It you do not give it enough information it will default to length 8 for numbers and length $8 for character variables.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 02:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-Statement/m-p/244122#M56009</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-01-18T02:10:37Z</dc:date>
    </item>
  </channel>
</rss>

