<?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: Why does proc import not import column labels from xls ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822632#M324842</link>
    <description>&lt;P&gt;Not sure why you are not seeing the whole name.&lt;/P&gt;
&lt;P&gt;What tool did you use to view the dataset so that you could take that photograph you pasted?&lt;/P&gt;
&lt;P&gt;What does PROC CONTENTS show?&lt;/P&gt;
&lt;P&gt;Remember that the NAME of a variable can only be 32 bytes long.&amp;nbsp; And unless you have (accidentally?) set the VALIDVARNAME option to ANY it cannot include spaces and other special characters.&amp;nbsp; But the original header cell value should be stored in the LABEL of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;6    proc import datafile='c:\downloads\example.xls' dbms=xls out=test replace;
7    run;

NOTE:    Variable Name Change.  Space in name -&amp;gt; Space_in_name
NOTE:    Variable Name Change.  Linebreak
in name -&amp;gt; Linebreak_in_name
NOTE:    Variable Name Change.  Name that is more than thirty-tw -&amp;gt; Name_that_is_more_than_thirty_tw
NOTE: The import data set has 1 observations and 4 variables.
NOTE: WORK.TEST data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


8
9    proc contents data=test varnum out=contents;
10   run;

NOTE: The data set WORK.CONTENTS has 4 observations and 41 variables.
NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


11
12   proc print data=contents;
13     var varnum name type length label;
14   run;

NOTE: There were 4 observations read from the data set WORK.CONTENTS.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.01 seconds
&lt;/PRE&gt;
&lt;PRE&gt;                                             Variables in Creation Order

#    Variable                            Type    Len    Format     Label

1    ID                                  Num       8    BEST12.    ID
2    Space_in_name                       Num       8    BEST12.    Space in name
3    Linebreak_in_name                   Num       8    BEST20.    Linebreak
in name
4    Name_that_is_more_than_thirty_tw    Num       8    BEST12.    Name that is more than thirty-two characters long
&amp;#12;

Obs    VARNUM    NAME                                TYPE    LENGTH    LABEL

 1        1      ID                                    1        8      ID
 2        3      Linebreak_in_name                     1        8      Linebreak
in name
 3        4      Name_that_is_more_than_thirty_tw      1        8      Name that is more than thirty-two characters long
 4        2      Space_in_name                         1        8      Space in name
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jul 2022 19:25:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-07-11T19:25:20Z</dc:date>
    <item>
      <title>Why does proc import not import column labels from xls ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822617#M324836</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an xls worksheet as follows:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_0-1657565271980.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73152iE92A26FC2F7A7E19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_0-1657565271980.png" alt="inquistive_0-1657565271980.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Upon export this is the output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_1-1657565338660.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73153iEEE9FD07430EB70B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_1-1657565338660.png" alt="inquistive_1-1657565338660.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;My question is- why is SAS unable to import the column label (for the COMMENTS column) when I click that particular cell, only the COMMENTS is seen on the bar above .All others are displayed in full. Any idea what is the problem with this cell?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_2-1657565606694.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73154i64BD4683F267C12E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_2-1657565606694.png" alt="inquistive_2-1657565606694.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All others are okay.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_3-1657565638703.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73155iACB860A347A63FEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_3-1657565638703.png" alt="inquistive_3-1657565638703.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe the cell format is causing SAS not to import all info from that cell. Please advise what troubleshooting steps are required to import the column label(s)( Not sure if this is the right term though).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 18:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822617#M324836</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2022-07-11T18:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why does proc import not import column labels from xls ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822619#M324838</link>
      <description>&lt;P&gt;I see nothing SAS-y here, only Excel screenshots. Have you actually done&amp;nbsp;&lt;EM&gt;anything&lt;/EM&gt; in SAS?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 19:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822619#M324838</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-11T19:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why does proc import not import column labels from xls ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822622#M324839</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import out= test_tmp
			datafile="C:\Users\test.xls"
            dbms =xls replace;
            getnames= yes;
run;

proc export data= test_tmp
			outfile = "C:\Users\test2.xls"
			dbms = excel replace;
			sheet = 'test1';  
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jul 2022 19:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822622#M324839</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2022-07-11T19:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why does proc import not import column labels from xls ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822624#M324840</link>
      <description>&lt;P&gt;The string&lt;/P&gt;
&lt;PRE&gt;COMMENTS FULL TIME STUDENT OR WORKING?&lt;/PRE&gt;
&lt;P&gt;is too long for a SAS name (maximum 32 characters), so it is shortened by PROC IMPORT.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 19:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822624#M324840</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-11T19:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why does proc import not import column labels from xls ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822630#M324841</link>
      <description>&lt;P&gt;Comments looks like it has an new line/end of line character in that field which means it would truncate at the end of the line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually that gets entered into Excel when you hit ALT+ENTER in a cell.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 19:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822630#M324841</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-11T19:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why does proc import not import column labels from xls ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822632#M324842</link>
      <description>&lt;P&gt;Not sure why you are not seeing the whole name.&lt;/P&gt;
&lt;P&gt;What tool did you use to view the dataset so that you could take that photograph you pasted?&lt;/P&gt;
&lt;P&gt;What does PROC CONTENTS show?&lt;/P&gt;
&lt;P&gt;Remember that the NAME of a variable can only be 32 bytes long.&amp;nbsp; And unless you have (accidentally?) set the VALIDVARNAME option to ANY it cannot include spaces and other special characters.&amp;nbsp; But the original header cell value should be stored in the LABEL of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;6    proc import datafile='c:\downloads\example.xls' dbms=xls out=test replace;
7    run;

NOTE:    Variable Name Change.  Space in name -&amp;gt; Space_in_name
NOTE:    Variable Name Change.  Linebreak
in name -&amp;gt; Linebreak_in_name
NOTE:    Variable Name Change.  Name that is more than thirty-tw -&amp;gt; Name_that_is_more_than_thirty_tw
NOTE: The import data set has 1 observations and 4 variables.
NOTE: WORK.TEST data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


8
9    proc contents data=test varnum out=contents;
10   run;

NOTE: The data set WORK.CONTENTS has 4 observations and 41 variables.
NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


11
12   proc print data=contents;
13     var varnum name type length label;
14   run;

NOTE: There were 4 observations read from the data set WORK.CONTENTS.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.01 seconds
&lt;/PRE&gt;
&lt;PRE&gt;                                             Variables in Creation Order

#    Variable                            Type    Len    Format     Label

1    ID                                  Num       8    BEST12.    ID
2    Space_in_name                       Num       8    BEST12.    Space in name
3    Linebreak_in_name                   Num       8    BEST20.    Linebreak
in name
4    Name_that_is_more_than_thirty_tw    Num       8    BEST12.    Name that is more than thirty-two characters long
&amp;#12;

Obs    VARNUM    NAME                                TYPE    LENGTH    LABEL

 1        1      ID                                    1        8      ID
 2        3      Linebreak_in_name                     1        8      Linebreak
in name
 3        4      Name_that_is_more_than_thirty_tw      1        8      Name that is more than thirty-two characters long
 4        2      Space_in_name                         1        8      Space in name
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 19:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/822632#M324842</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-11T19:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why does proc import not import column labels from xls ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/823418#M325114</link>
      <description>Hi  Reeza,&lt;BR /&gt;I found it to be exactly as you suspected- there are multiple lines entered after hitting ALT+ENTER. And the end users have done it by design, not by mistake. Is there a way to tell SAS to go to consecutive lines and read/fetch them(values)?</description>
      <pubDate>Thu, 14 Jul 2022 20:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/823418#M325114</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2022-07-14T20:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why does proc import not import column labels from xls ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/823424#M325118</link>
      <description>&lt;P&gt;It should be doing that already.&amp;nbsp; Did you run proc contents on the dataset?&amp;nbsp; What does it show as the variable name? What does it show as the label?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a RENAME statement to change the name of a variable.&lt;/P&gt;
&lt;P&gt;You can use a LABEL statement to change the label attached to a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can fix it after the fact.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=have noprint out=contents; run;
data fixes ;
  set have;
  where indexc(name||label,'0A0D'x);
  length newname $32 newlabel $256 ;
  newname = left(compbl(translate(name,'  ','0A0D'x)));
  newlabel = left(compbl(translate(label,'  ','0A0D'x)));
run;
proc sql noprint;
select&lt;BR /&gt;    case when (upcase(name) ne upcase(newname)) 
         then catx(' ',nliteral(name),nliteral(newname))
    else ' ' end
  , catx('=',nliteral(newname),quote(trim(label),"'"))
  into :rename separated by ' '
     , :label separated by ' '
  from fixed
;
quit;

data want ;
  set have;
  rename &amp;amp;rename ;
  label &amp;amp;label;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jul 2022 20:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-proc-import-not-import-column-labels-from-xls/m-p/823424#M325118</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-14T20:55:48Z</dc:date>
    </item>
  </channel>
</rss>

