<?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: var name length greater than 32 characters in CSV file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877107#M346501</link>
    <description>&lt;P&gt;We aren't support.&amp;nbsp; Just other interested SAS users.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you make a trivial example that demonstrates the issue?&amp;nbsp; Just a few lines and a few fields per line.&amp;nbsp; Post the example text using the pop-up window that opens when you click on the Insert Code button (looks like &amp;lt; / &amp;gt; ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no need to use PROC IMPORT to read a CSV file.&amp;nbsp; You can write your own data step to read it and then you have full control over the variable names.&amp;nbsp; Personally I rarely use variable names that are longer than 8 characters as it just makes using the data harder.&amp;nbsp; Longer descriptions of the meaning of a variable can be placed in the variable LABEL instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot recreate your issue.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
options parmcards=csv;
parmcards;
id,this_name_is_longer_than_thirty_two_charaters,number
abc,xyz,123
;

proc import file=csv dbms=csv out=want replace;
run;

proc contents data=want noprint out=contents; run;

data _null_;
  set contents;
  namelen=length(name);
  put (varnum namelen name label) (=);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;652  data _null_;
653    set contents;
654    namelen=length(name);
655    put (varnum namelen name label) (=);
656  run;

VARNUM=1 namelen=2 NAME=id LABEL=
VARNUM=3 namelen=6 NAME=number LABEL=
VARNUM=2 namelen=32 NAME=this_name_is_longer_than_thirty_ LABEL=
NOTE: There were 3 observations read from the data set WORK.CONTENTS.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
    <pubDate>Tue, 23 May 2023 16:10:08 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-05-23T16:10:08Z</dc:date>
    <item>
      <title>var name length greater than 32 characters in CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877104#M346498</link>
      <description>&lt;P&gt;Dear Support,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I import a csv file, which contains a variable name with length of 34 characters, since SAS variable name can only have 32 characters, what I expected is the last 2 characters will be truncated, then the variable name in SAS dataset should be 32 characters long, however, after the import, the variable name contains 33 characters, which cause other problems, I cannot use the variable name in my program to assign this variable to another variable. Could you please advise how we should handle the problem? Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;xiumei&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 15:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877104#M346498</guid>
      <dc:creator>yangx</dc:creator>
      <dc:date>2023-05-23T15:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: var name length greater than 32 characters in CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877107#M346501</link>
      <description>&lt;P&gt;We aren't support.&amp;nbsp; Just other interested SAS users.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you make a trivial example that demonstrates the issue?&amp;nbsp; Just a few lines and a few fields per line.&amp;nbsp; Post the example text using the pop-up window that opens when you click on the Insert Code button (looks like &amp;lt; / &amp;gt; ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no need to use PROC IMPORT to read a CSV file.&amp;nbsp; You can write your own data step to read it and then you have full control over the variable names.&amp;nbsp; Personally I rarely use variable names that are longer than 8 characters as it just makes using the data harder.&amp;nbsp; Longer descriptions of the meaning of a variable can be placed in the variable LABEL instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot recreate your issue.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
options parmcards=csv;
parmcards;
id,this_name_is_longer_than_thirty_two_charaters,number
abc,xyz,123
;

proc import file=csv dbms=csv out=want replace;
run;

proc contents data=want noprint out=contents; run;

data _null_;
  set contents;
  namelen=length(name);
  put (varnum namelen name label) (=);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;652  data _null_;
653    set contents;
654    namelen=length(name);
655    put (varnum namelen name label) (=);
656  run;

VARNUM=1 namelen=2 NAME=id LABEL=
VARNUM=3 namelen=6 NAME=number LABEL=
VARNUM=2 namelen=32 NAME=this_name_is_longer_than_thirty_ LABEL=
NOTE: There were 3 observations read from the data set WORK.CONTENTS.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2023 16:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877107#M346501</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-23T16:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: var name length greater than 32 characters in CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877109#M346503</link>
      <description>I suspect it's being read in with 32 characters for the name but the label is longer. Run a proc contents on the data set and check the variable name and label. &lt;BR /&gt;&lt;BR /&gt;Also, set the following so that the typical SAS naming convention will apply.&lt;BR /&gt;&lt;BR /&gt;options validvarname=v7;&lt;BR /&gt;</description>
      <pubDate>Tue, 23 May 2023 16:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877109#M346503</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-23T16:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: var name length greater than 32 characters in CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877152#M346523</link>
      <description>&lt;P&gt;Thanks for your reply, I have figured out where the problem is. Now proc import works as expected, the last two characters were truncated, so the variable name has 32 characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Xiumei&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 19:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/var-name-length-greater-than-32-characters-in-CSV-file/m-p/877152#M346523</guid>
      <dc:creator>yangx</dc:creator>
      <dc:date>2023-05-23T19:45:46Z</dc:date>
    </item>
  </channel>
</rss>

