<?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: Longer variable name...more than 32 characters. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631382#M187078</link>
    <description>&lt;P&gt;In general I find it easier to write my own data steps to read CSV files.&amp;nbsp; If you do that you can assign any name you want for the columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not have the problem the way you have described it.&amp;nbsp; When I use PROC IMPORT to read a file where there a names that match in the first 32 bytes then it makes up a unique name for the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example let's make a test file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
data _null_;
  file csv dsd ;
  length name $40 ;
  do i=1 to 5 ;
    name = cats(substr(repeat('this_name_is_too_long_',10),1,35),I);
    put name @;
  end;
  put;
  do i=1 to 5;
    put i @;
  end;
  put;
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And try to read it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile=csv dbms=csv out=test replace ; run;
proc print data=test; run;
proc contents data=test varnum; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;        this_name_
       is_too_long_
Obs     this_name_             VAR2            VAR3            VAR4            VAR5

 1                1               2               3               4               5

                        Variables in Creation Order

#    Variable                            Type    Len    Format     Informat

1    this_name_is_too_long_this_name_    Num       8    BEST12.    BEST32.
2    VAR2                                Num       8    BEST12.    BEST32.
3    VAR3                                Num       8    BEST12.    BEST32.
4    VAR4                                Num       8    BEST12.    BEST32.
5    VAR5                                Num       8    BEST12.    BEST32.
&lt;/PRE&gt;
&lt;P&gt;Now if you want you can read the first line of the file use it as LABELs for the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=test(obs=0) out=names ;
  var _all_;
run;

filename code temp;
data names ;
  length _name_ $32 _label_ $256 ;
  set names;
  infile csv dsd truncover obs=1;
  input _label_ @@;
  file code;
  put 'label ' _name_ '=' _label_ :$quote. ';' ;
run;

proc datasets nolist lib=work;
  modify test ;
%include code / source2;
  run;
quit;
proc contents data=test varnum; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;                                      Variables in Creation Order

#  Variable                          Type  Len  Format   Informat  Label

1  this_name_is_too_long_this_name_  Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_1
2  VAR2                              Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_2
3  VAR3                              Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_3
4  VAR4                              Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_4
5  VAR5                              Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_5

&lt;/PRE&gt;</description>
    <pubDate>Wed, 11 Mar 2020 21:18:44 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-03-11T21:18:44Z</dc:date>
    <item>
      <title>Longer variable name...more than 32 characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631372#M187072</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I have an csv excel file with lot of columns. I need to import this file and when I import it not all variables are imported as expected...that's because some of the columns length exceeds more than 32 characters...So suppose this example variable has a name &lt;FONT color="#FF0000"&gt;valid_sas_long_variablenumber_one &lt;FONT color="#000000"&gt;with length of 33 and then there is another similar variable called&amp;nbsp;&lt;FONT color="#FF0000"&gt;valid_sas_longvariablenumber1&amp;nbsp;&amp;nbsp;&lt;FONT color="#000000"&gt;with length of 28 so in my imported dataset the other longer length variable is getting overwritten and sas is considering only one variable&amp;nbsp;valid_sas_longvariablenumber1. Is there a work around for this one. Can someone please help. I have numerous variables like this.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;Thanks,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;Rasikha&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 20:49:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631372#M187072</guid>
      <dc:creator>Aidaan_10</dc:creator>
      <dc:date>2020-03-11T20:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Longer variable name...more than 32 characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631378#M187076</link>
      <description>You cannot have variable names over 32 characters and there is currently no workaround for that. You will need to rename them manually in one fashion or another. The easiest method, IMO is to read the file using PROC IMPORT (assuming you have a CSV). Then get the code from the log and fix the names I need to. &lt;BR /&gt;&lt;BR /&gt;Note that a CSV means comma separated value and Excel opens these files, but they're actually text files. And Excel will interpret types as well, so it doesn't always read the files correctly.</description>
      <pubDate>Wed, 11 Mar 2020 21:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631378#M187076</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-11T21:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Longer variable name...more than 32 characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631382#M187078</link>
      <description>&lt;P&gt;In general I find it easier to write my own data steps to read CSV files.&amp;nbsp; If you do that you can assign any name you want for the columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not have the problem the way you have described it.&amp;nbsp; When I use PROC IMPORT to read a file where there a names that match in the first 32 bytes then it makes up a unique name for the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example let's make a test file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
data _null_;
  file csv dsd ;
  length name $40 ;
  do i=1 to 5 ;
    name = cats(substr(repeat('this_name_is_too_long_',10),1,35),I);
    put name @;
  end;
  put;
  do i=1 to 5;
    put i @;
  end;
  put;
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And try to read it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile=csv dbms=csv out=test replace ; run;
proc print data=test; run;
proc contents data=test varnum; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;        this_name_
       is_too_long_
Obs     this_name_             VAR2            VAR3            VAR4            VAR5

 1                1               2               3               4               5

                        Variables in Creation Order

#    Variable                            Type    Len    Format     Informat

1    this_name_is_too_long_this_name_    Num       8    BEST12.    BEST32.
2    VAR2                                Num       8    BEST12.    BEST32.
3    VAR3                                Num       8    BEST12.    BEST32.
4    VAR4                                Num       8    BEST12.    BEST32.
5    VAR5                                Num       8    BEST12.    BEST32.
&lt;/PRE&gt;
&lt;P&gt;Now if you want you can read the first line of the file use it as LABELs for the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=test(obs=0) out=names ;
  var _all_;
run;

filename code temp;
data names ;
  length _name_ $32 _label_ $256 ;
  set names;
  infile csv dsd truncover obs=1;
  input _label_ @@;
  file code;
  put 'label ' _name_ '=' _label_ :$quote. ';' ;
run;

proc datasets nolist lib=work;
  modify test ;
%include code / source2;
  run;
quit;
proc contents data=test varnum; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;                                      Variables in Creation Order

#  Variable                          Type  Len  Format   Informat  Label

1  this_name_is_too_long_this_name_  Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_1
2  VAR2                              Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_2
3  VAR3                              Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_3
4  VAR4                              Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_4
5  VAR5                              Num     8  BEST12.  BEST32.   this_name_is_too_long_this_name_is_5

&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Mar 2020 21:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631382#M187078</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-11T21:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Longer variable name...more than 32 characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631401#M187084</link>
      <description>&lt;P&gt;Time to &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Metadata-More-space-please/idi-p/220310" target="_self"&gt;vote&lt;/A&gt;!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 22:09:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/631401#M187084</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-11T22:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: Longer variable name...more than 32 characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/823808#M325329</link>
      <description>&lt;P&gt;I have that same issue when i did a transpose and i fixed that with this way.&lt;/P&gt;&lt;P&gt;1)I keep variables which i was needed and after that just done transpose and add &lt;STRONG&gt;By&lt;/STRONG&gt; variables which i needed and didn't mentioned &lt;U&gt;&lt;STRONG&gt;VAR&lt;/STRONG&gt; &lt;/U&gt;that variables just like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc Sort Data = Test; By Var1 var2; Run;&lt;/P&gt;&lt;P&gt;Proc Transpose Data = Test out = Test_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; By var1, var2;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 11:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Longer-variable-name-more-than-32-characters/m-p/823808#M325329</guid>
      <dc:creator>Manvel</dc:creator>
      <dc:date>2022-07-18T11:24:07Z</dc:date>
    </item>
  </channel>
</rss>

