<?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: Long name of variables for proc import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983565#M379514</link>
    <description>&lt;P&gt;It might notice it, but unlike when using VALIDVARNAME=V7 it takes no action to FIX it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if you do the same test with duplicate column headers that are shorter than 32 bytes then PROC IMPORT when run with VALIDVARNAME=ANY will detect and FIX the duplicate names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=csv;
filename csv temp;
parmcards4;
id,a,a,b,b
1,2,3,4,5
;;;;

options validvarname=v7;
proc import dbms=csv file=csv out=v7 replace;
run;
options validvarname=any;
proc import dbms=csv file=csv out=any replace;
run;

proc compare data=any compare=v7 listall;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Feb 2026 19:11:43 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2026-02-16T19:11:43Z</dc:date>
    <item>
      <title>Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983488#M379495</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 2 variables : "Parc mondial - Taux de logements vacants* (en %)"n&amp;nbsp; and "Parc mondial - Taux de logements individuels (en %)"n, but while importing I have only the variable "Parc mondial - Taux de logements"n.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How I can import the 2 variables (over 32 characters, csv file) ? The problem is that the variables beginning with the same&amp;nbsp;characters. Maybe there is some option in sas.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Feb 2026 16:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983488#M379495</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2026-02-14T16:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983490#M379496</link>
      <description>&lt;P&gt;Use proper names in the source. What you show is suitable for labels, but never for names, in ANY programming environment.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Feb 2026 17:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983490#M379496</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2026-02-14T17:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983491#M379497</link>
      <description>&lt;P&gt;PS 32 bytes is a hard, physical limit. It is the length reserved for names in the header structure of .sas7bdat files and anywhere else in the SAS language.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Feb 2026 17:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983491#M379497</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2026-02-14T17:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983496#M379499</link>
      <description>&lt;P&gt;Since the data is in a CSV file there is no need to "IMPORT" it.&amp;nbsp; Instead you can just READ the file directly into a dataset.&amp;nbsp; Then you can use any NAME you want for the data in the columns with those headers.&amp;nbsp; You can put the long strings in the header line into the LABEL of the variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'have.csv' dsd firstobs=2 truncover ;
  length  vacants individuels 8;
  label vacants = 'Parc mondial - Taux de logements vacants* (en %)'
        individuels = 'Parc mondial - Taux de logements individuels (en %)'
  ;
  input vacants individuels;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need a tool to try and make GUESSes about how to read in a CSV file instead of using PROC IMPORT try using this macro:&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/csv2ds.sas" target="_blank" rel="noopener"&gt;https://github.com/sasutils/macros/blob/master/csv2ds.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It can handle creating unique names for columns whose headers are the same for the first 32 bytes.&amp;nbsp; Plus it will always attach a label to the variable when the column header is not exactly the same as the name of the variable it creates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's make an example and test them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
options parmcards=csv;
parmcards4;
id,Parc mondial - Taux de logements vacants* (en %),Parc mondial - Taux de logements individuels (en %)
1,10,20
2,20,30
3,25,45
;;;;

options validvarname=any;
proc import dbms=csv file=csv out=import replace;
run;
%csv2ds(csv,out=csv2ds,replace=yes)
proc compare data=import compare=csv2ds listall;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When you run with VALIDVARNAME=ANY you will still get those non-standard variable names that will require using name literals to reference, but will will get a numeric suffix on the second one so that the names are different.&lt;/P&gt;
&lt;PRE&gt;Listing of Variables in WORK.CSV2DS but not in WORK.IMPORT                                                                          
                                                                                                                                    
Variable                          Type  Length  Label                                                                               
                                                                                                                                    
Parc mondial - Taux de logemen_1  Num        8  Parc mondial - Taux de logements individuels (en %)   &lt;/PRE&gt;
&lt;P&gt;And if you run with VALIDVARNAME=V7 (which I encourage so that SAS does not generate non-standard variable names) then %CSV2DS will actually be able to make more descriptive long names since it will collapse the ' - ' into a single underscore so that the names will differ in the 32nd byte.&lt;/P&gt;
&lt;PRE&gt;Listing of Variables in WORK.IMPORT but not in WORK.CSV2DS                                                                          
                                                                                                                                    
Variable                          Type  Length  Format   Informat                                                                   
                                                                                                                                    
Parc_mondial___Taux_de_logements  Num        8  BEST12.  BEST32.                                                                    
VAR3                              Num        8  BEST12.  BEST32.                                                                    
                                                                                                                                    
                                                                                                                                    
Listing of Variables in WORK.CSV2DS but not in WORK.IMPORT                                                                          
                                                                                                                                    
Variable                          Type  Length  Label                                                                               
                                                                                                                                    
Parc_mondial_Taux_de_logements_v  Num        8  Parc mondial - Taux de logements vacants* (en %)                                    
Parc_mondial_Taux_de_logements_i  Num        8  Parc mondial - Taux de logements individuels (en %)    &lt;/PRE&gt;
&lt;P&gt;You can see more of the advantages of using %CSV2DS() by reading the comments in the code.&lt;/P&gt;
&lt;PRE&gt;Differences from PROC IMPORT
- Supports header lines with more than 32,767 characters
- Supports ZIP and GZIP source files
- Generates unique variable names by adding numeric suffix
- Does not overestimate maxlength when longest value is quoted
- Does NOT force character type if all values are quoted
- Generates label when generated variable name is different than header
- Supports NAMEROW option
- Supports numeric fields with special missing values (MISSING statement)
- Does not attach unneeded informats or formats
- Allows overriding calculated metadata
- Allow using random sample of rows to guess metadata
- Generates more compact SAS code
- Generates analysis summary dataset and raw data view
- Saves generated SAS code to a file
- Forces DATE and DATETIME formats to show century
- Difference in generated V7 compatible variable names
  - Replaces adjacent non-valid characters with single underscore&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Feb 2026 16:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983496#M379499</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-02-15T16:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983502#M379500</link>
      <description>&lt;P&gt;The max length of variable in SAS is 32, so you are unable to use "&amp;gt;32 string" to make a variable name. But you can make it as variable label:&lt;/P&gt;
&lt;P&gt;Firstly import this csv file with option getname= and datarow=&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc import datafile='c:\temp\temp.csv' out=have dbms=csv replace;
&lt;STRONG&gt;getnames=no;
datarow=2;&lt;/STRONG&gt;
run;
&lt;/PRE&gt;
&lt;P&gt;Secondly, label these variables with the first row:&lt;/P&gt;
&lt;PRE&gt;
options obs=1;
proc import datafile='c:\temp\temp.csv' out=label dbms=csv replace;
getnames=no;
run;
option obs=max;

proc transpose data=label out=label2;
var _all_;
run;
data _null_;
set label2 end=last;
if _n_=1 then call execute('proc datasets library=work nolist nodetails;modify have;label ');
call execute(catt(_name_,'="',col1,'"'));
if last then call execute(';quit;');
run;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Feb 2026 02:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983502#M379500</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-02-15T02:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983504#M379502</link>
      <description>&lt;P&gt;Note looking at my SAS log I noticed that PROC IMPORT has a BUG that this example demonstrates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When it is run using VALIDVARNAME=V7 is properly detects that the two variables are trying to use the same name&lt;/P&gt;
&lt;PRE&gt; Name Parc mondial - Taux de logements vacants* (en %) truncated to Parc_mondial___Taux_de_logements.
 Name Parc mondial - Taux de logements individuels (en %) truncated to Parc_mondial___Taux_de_logements.
 Name Parc_mondial___Taux_de_logements is a duplicate.&lt;/PRE&gt;
&lt;P&gt;and automatically changes the second one to VAR3 instead.&lt;/P&gt;
&lt;PRE&gt; 96                informat id best32. ;
 97                informat Parc_mondial___Taux_de_logements best32. ;
 98                informat VAR3 best32. ;
 99                format id best12. ;
 100               format Parc_mondial___Taux_de_logements best12. ;
 101               format VAR3 best12. ;
 102            input
 103                        id
 104                        Parc_mondial___Taux_de_logements
 105                        VAR3
 106            ;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when run using VALIDVARNAME=ANY it does not notice.&amp;nbsp; So it uses the same name twice in the INFORMAT, FORMAT and INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 96                informat id best32. ;
 97                informat "Parc mondial - Taux de logements"N best32. ;
 98                informat "Parc mondial - Taux de logements"N best32. ;
 99                format id best12. ;
 100               format "Parc mondial - Taux de logements"N best12. ;
 101               format "Parc mondial - Taux de logements"N best12. ;
 102            input
 103                        id
 104                        "Parc mondial - Taux de logements"N
 105                        "Parc mondial - Taux de logements"N
 106            ;&lt;/PRE&gt;
&lt;P&gt;resulting in a dataset with 2 instead of 3 variables.&lt;/P&gt;
&lt;PRE&gt;NOTE: The data set WORK.IMPORT has 3 observations and 2 variables.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Feb 2026 03:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983504#M379502</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-02-15T03:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983527#M379506</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;I believe SAS does notice the problem with PROC IMPORT and VALIDVARNAME=ANY. In my log I see the following line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;11   proc import dbms=csv file=csv out=import replace;
12   run;

Name Parc mondial - Taux de logements vacants* (en %) truncated to Parc mondial - Taux de logements.
Name Parc mondial - Taux de logements individuels (en %) truncated to Parc mondial - Taux de
logements.
Problems were detected with provided names.  See LOG.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The DATA Step code that is run behind the scenes will generate the Informat, Input, and Format statements for each variable; but since there are duplicates, it is only keeping the last one. That is why the values that are stored for&amp;nbsp;Parc mondial - Taux de logements are 20, 30, 45.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Feb 2026 12:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983527#M379506</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2026-02-16T12:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983565#M379514</link>
      <description>&lt;P&gt;It might notice it, but unlike when using VALIDVARNAME=V7 it takes no action to FIX it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if you do the same test with duplicate column headers that are shorter than 32 bytes then PROC IMPORT when run with VALIDVARNAME=ANY will detect and FIX the duplicate names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=csv;
filename csv temp;
parmcards4;
id,a,a,b,b
1,2,3,4,5
;;;;

options validvarname=v7;
proc import dbms=csv file=csv out=v7 replace;
run;
options validvarname=any;
proc import dbms=csv file=csv out=any replace;
run;

proc compare data=any compare=v7 listall;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Feb 2026 19:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983565#M379514</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-02-16T19:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983577#M379515</link>
      <description>Thank you, Tom!</description>
      <pubDate>Mon, 16 Feb 2026 19:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983577#M379515</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2026-02-16T19:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983585#M379516</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;In a silly but technical sense, what you are saying is not correct. Before I retired from SAS, I used to run tests with n-literals like these to both expose bugs and to demonstrate my contention that n-literals like these should be prohibited. They were not, and as silly as it is, this is perfectly legitimate SAS code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;
data sillynlit;
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""         "n = 'silly double quote n-lit';
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''         'n = 'silly single quote n-lit';
output;
run;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2026 00:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983585#M379516</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2026-02-17T00:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983586#M379517</link>
      <description>Thank you . This is really a bug.</description>
      <pubDate>Tue, 17 Feb 2026 01:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983586#M379517</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-02-17T01:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Long name of variables for proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983591#M379519</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16777"&gt;@WarrenKuhfeld&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;In a silly but technical sense, what you are saying is not correct. Before I retired from SAS, I used to run tests with n-literals like these to both expose bugs and to demonstrate my contention that n-literals like these should be prohibited. They were not, and as silly as it is, this is perfectly legitimate SAS code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;
data sillynlit;
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""         "n = 'silly double quote n-lit';
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''         'n = 'silly single quote n-lit';
output;
run;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No.&amp;nbsp; Technically what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;said is TRUE. The maximum length of a variable name is 32 bytes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you are talking about is the maximum length of the TOKEN used in the SAS code to represent the variable name in the code.&amp;nbsp; The maximum length of that token would be one that was all the same quote character.&amp;nbsp; So 32*2 quotes for the actual name and then 2 more quotes and the letter N to make a name literal for a total length of 67 bytes.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2026 02:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-name-of-variables-for-proc-import/m-p/983591#M379519</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-02-17T02:53:21Z</dc:date>
    </item>
  </channel>
</rss>

