<?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: Character length cannot be used with numeric variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730917#M227667</link>
    <description>OMG, disaster!&lt;BR /&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt; . I just notice the character and numeric and forget the syntax error.&lt;BR /&gt;....</description>
    <pubDate>Fri, 02 Apr 2021 05:32:05 GMT</pubDate>
    <dc:creator>ResoluteCarbon</dc:creator>
    <dc:date>2021-04-02T05:32:05Z</dc:date>
    <item>
      <title>Character length cannot be used with numeric variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730909#M227662</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Today when I run the code as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data np_parks;
	set pg2.np_final;
	putlog "NOTE:START DATASTEP ITERATION"
	keep Region ParkName AvgMonthlyVisitors Acres Size;
	LENGTH Size $6.;
    where Type="PARK";
	PUTLOG tYPE;
	format AvgMonthlyVisitors Acres comma10.;
    Type=propcase(Type);
	AvgMonthlyVisitors=sum(DayVisits,Campers,OtherLodging)/12;
	if Acres&amp;lt;1000 then Size="Small";
	else if Acres&amp;lt;100000 then Size="Medium";
	else Size="Large";
	PUTLOG='CONTENT';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the original datasetpg2.np_final, there is no column for Size, so Size just being written to PDV after the compilation progress going through all the data statement in this data step. I am wondering why it causes an error in the log as below&lt;/P&gt;
&lt;PRE&gt;56         data np_parks;
57         	set pg2.np_final;
58         	putlog "NOTE:START DATASTEP ITERATION"
59         	keep Region ParkName AvgMonthlyVisitors Acres Size;
60         	LENGTH Size $6.;
&lt;STRONG&gt;ERROR: Character length cannot be used with numeric variable Size.&lt;/STRONG&gt;
61             where Type="PARK";
62         	PUTLOG tYPE;
63         	format AvgMonthlyVisitors Acres comma10.;
64             Type=propcase(Type);
65         	AvgMonthlyVisitors=sum(DayVisits,Campers,OtherLodging)/12;
66         	if Acres&amp;lt;1000 then Size="Small";
67         	else if Acres&amp;lt;100000 then Size="Medium";
68         	else Size="Large";
69         	PUTLOG='CONTENT';
70         run;&lt;/PRE&gt;
&lt;P&gt;It is quite clear to me that Size is a character rather than a numeric variable.&lt;/P&gt;
&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 04:43:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730909#M227662</guid>
      <dc:creator>ResoluteCarbon</dc:creator>
      <dc:date>2021-04-02T04:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Character length cannot be used with numeric variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730910#M227663</link>
      <description>Can you change the LENGTH statement to FORMAT? I am not sure why the error unless I see the first few observations of the input data set.</description>
      <pubDate>Fri, 02 Apr 2021 05:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730910#M227663</guid>
      <dc:creator>qoit</dc:creator>
      <dc:date>2021-04-02T05:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Character length cannot be used with numeric variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730915#M227665</link>
      <description>&lt;P&gt;&lt;BR /&gt;Because there is no semicolon after&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;putlog "NOTE:START DATASTEP ITERATION"&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Apr 2021 05:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730915#M227665</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-02T05:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Character length cannot be used with numeric variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730916#M227666</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/246836"&gt;@qoit&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first few lines of the input are as below&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ResoluteCarbon_0-1617341348459.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56833i02B2E164D876D7CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="ResoluteCarbon_0-1617341348459.png" alt="ResoluteCarbon_0-1617341348459.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And could you please let me know why I should change from length to format. Because length is to assign the length for a variable in the PDV while format just for displaying purpose. I am wondering you are mentioning &lt;STRONG&gt;informat&lt;/STRONG&gt;&amp;nbsp; rather than format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 05:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730916#M227666</guid>
      <dc:creator>ResoluteCarbon</dc:creator>
      <dc:date>2021-04-02T05:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Character length cannot be used with numeric variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730917#M227667</link>
      <description>OMG, disaster!&lt;BR /&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt; . I just notice the character and numeric and forget the syntax error.&lt;BR /&gt;....</description>
      <pubDate>Fri, 02 Apr 2021 05:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-length-cannot-be-used-with-numeric-variable/m-p/730917#M227667</guid>
      <dc:creator>ResoluteCarbon</dc:creator>
      <dc:date>2021-04-02T05:32:05Z</dc:date>
    </item>
  </channel>
</rss>

