<?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: How to increase the length of character value in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733424#M28575</link>
    <description>&lt;P&gt;do the "charvar1-charvar100" represent the first and last variables in the data? Am asking this b/c i am getting&amp;nbsp; error when i use the first and last variables in the data. Does it need to have 1 - 100 at the end of the variable names as well?&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;charvar1-charvar100&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;this is the error I am getting in the log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Variable referral1 cannot be found on the list of previously defined variables.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Apr 2021 18:57:49 GMT</pubDate>
    <dc:creator>hjjijkkl</dc:creator>
    <dc:date>2021-04-13T18:57:49Z</dc:date>
    <item>
      <title>How to increase the length of character value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733406#M28573</link>
      <description>&lt;P&gt;I have a data with 100 + variables and each variable have a very long character values. How can I increase the length of all variables all together ( I want to have the max length for all) instead of changing the length of the variables one by one. How can I do that in data step?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 18:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733406#M28573</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-13T18:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase the length of character value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733408#M28574</link>
      <description>&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp; &amp;nbsp; length charvar1-charvar100 $ 6000;
&amp;nbsp; &amp;nbsp; set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Apr 2021 18:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733408#M28574</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-13T18:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase the length of character value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733424#M28575</link>
      <description>&lt;P&gt;do the "charvar1-charvar100" represent the first and last variables in the data? Am asking this b/c i am getting&amp;nbsp; error when i use the first and last variables in the data. Does it need to have 1 - 100 at the end of the variable names as well?&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;charvar1-charvar100&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;this is the error I am getting in the log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Variable referral1 cannot be found on the list of previously defined variables.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 18:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733424#M28575</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-13T18:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase the length of character value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733434#M28576</link>
      <description>&lt;P&gt;That will work. Note that the dataset will have to be recreated; you cannot change the length of variables without that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, the max length of a char is $32767 and not 6000. If you have 100+ of those the disk space requirements can rapidly explode and burden your I/O subsystem. It may become unwieldy. Consider adding COMPRESS=YES to deal with some of the downsides of a large amount of long characters, especially if you have a fair percentage of missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach could be to reconsider the data modelling. A table with a large amount of character variables can often be transposed into a version with one long char plus an identifying variable. Of course that depends entirely on the case at hand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;-- Jan.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 19:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733434#M28576</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2021-04-13T19:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase the length of character value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733441#M28577</link>
      <description>I dont want to change the length of the variables. I want to change the length of the character within the variables. &lt;BR /&gt;Can you please provide me an example ?</description>
      <pubDate>Tue, 13 Apr 2021 19:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733441#M28577</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-13T19:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase the length of character value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733479#M28578</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I dont want to change the length of the variables. I want to change the length of the character within the variables. &lt;BR /&gt;Can you please provide me an example ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That make no sense.&amp;nbsp; SAS has two types of variables, floating point numbers and fixed length character strings.&lt;/P&gt;
&lt;P&gt;The length of character variable is the maximum number of bytes that can be stored in the variable. (Note with non-single byte encodings like UTF-8 some "characters" might take more than one byte to store).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to replace individual characters, like 'X', with something longer, like 'ABC', then use the TRANWRD() function.&lt;/P&gt;
&lt;P&gt;If you want to make that change to every character variable in the dataset then use an array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array _C _character_;
  do index=1 to dim(_C);
     _c[index] = tranwrd(_c[index],'X','ABC');
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But note that this could make the value too long to fit into the original maximum number of bytes that the variable was defined to allow.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which is back to the original answers you got when the question was interpeted as how the change definition of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To change the length of all of the character variables in an existing dataset you will want to re-define the variable BEFORE SAS looks at the variable's definition in the source dataset.&amp;nbsp; So set hte length BEFORE the SET statement.&amp;nbsp; This means you need to know the NAMES of the variables you want to change.&amp;nbsp; You could query the metadata of the existing dataset to see the names of the character variables. And then use that information to generate a LENGTH statement.&amp;nbsp; Here is one way. In this version any character variable will be defined with a length of 6000 and any numeric variable defined as length 8 (SAS floating point numbers use 8 bytes).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=have out=contents noprint; run;
proc sort data=contents; by varnum; run;

filename length temp;
data _null_;
  length name $80;
  set contents end=eof;
  file length;
  if _n_=1 then put 'length';
  name=nliteral(name);
  put name @;
  if type=1 then put length ;
  else put '$6000' ;
  if eof then put ';';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now just run a data step to copy the data and include that LENGTH statement before the SET statement.&amp;nbsp; Make sure to remove an $xxx formats attached to the variables (SAS has a bad habit of attaching these when you read data from external databases).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
%Include length / source2;
  set have;
  format _character_ ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Apr 2021 19:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733479#M28578</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-13T19:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase the length of character value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733502#M28580</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I dont want to change the length of the variables. I want to change the length of the character within the variables. &lt;BR /&gt;Can you please provide me an example ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to provide the example as what you ask can be interpreted several ways. One is to change font size so individual letters occupy more space when seen: "W" vs "&lt;FONT size="7"&gt;W&lt;FONT size="4"&gt;" for instance. Fonts however are not properties of data set variables.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Another would be to change language encoding from a single byte system such as ASCII where you have a numeric value of up to 255 (2 to the 8th power) or one byte of storage or to a language character set that uses a Double Byte character set because there are to many characters to be represented by one byte of storage which is related to many issues of National Language Support and file encoding.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Or just replacing an "A" with "ABC".&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 20:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733502#M28580</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-13T20:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase the length of character value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733531#M28581</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;do the "charvar1-charvar100" represent the first and last variables in the data? Am asking this b/c i am getting&amp;nbsp; error when i use the first and last variables in the data. Does it need to have 1 - 100 at the end of the variable names as well?&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;charvar1-charvar100&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;this is the error I am getting in the log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Variable referral1 cannot be found on the list of previously defined variables.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You never gave specific information, so I can't be specific and thus I used generic variable names. If you want specific code for your specific case, you have to give specific variable names. Important rule: the more information you give us about the problem, the more likely our solution will fit. And the converse is true as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your variable names are&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;dog gorilla giraffe rabbit chicken horta buffalo&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;then you have to use those names in the LENGTH statement.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 20:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-the-length-of-character-value/m-p/733531#M28581</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-13T20:59:36Z</dc:date>
    </item>
  </channel>
</rss>

