<?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 How can I get excel column names as sas dataset variable names? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31685#M6081</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;There are more than 200 columns in my excel file.&amp;nbsp; I want the excel column names as sas variable names and the first &lt;/P&gt;&lt;P&gt;row as sas labels. for the attached excel file, I want A,B,C,D as my sas dataset variables and Name, sex,height,weight&lt;/P&gt;&lt;P&gt;as their labels.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Jan 2012 00:54:44 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2012-01-18T00:54:44Z</dc:date>
    <item>
      <title>How can I get excel column names as sas dataset variable names?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31685#M6081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;There are more than 200 columns in my excel file.&amp;nbsp; I want the excel column names as sas variable names and the first &lt;/P&gt;&lt;P&gt;row as sas labels. for the attached excel file, I want A,B,C,D as my sas dataset variables and Name, sex,height,weight&lt;/P&gt;&lt;P&gt;as their labels.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jan 2012 00:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31685#M6081</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-01-18T00:54:44Z</dc:date>
    </item>
    <item>
      <title>How can I get excel column names as sas dataset variable names?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31686#M6082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am afraid that you need to process it after importing.&lt;/P&gt;&lt;P&gt;There is an option getnames=no for proc import, but adding labels need you do it by hand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jan 2012 03:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31686#M6082</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-01-18T03:56:55Z</dc:date>
    </item>
    <item>
      <title>How can I get excel column names as sas dataset variable names?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31687#M6083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Ksharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply. When using "getnames=no" option , sas variables will be F1,F2 ....I want the variables as A,B,C D ......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jan 2012 13:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31687#M6083</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-01-18T13:30:17Z</dc:date>
    </item>
    <item>
      <title>How can I get excel column names as sas dataset variable names?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31688#M6084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Linlin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the SAS assigned names in such cases are systematic, as are the Excel column names, can't you achieve what you want by using KSharp's proposed method and a slight bit of post-processing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following can probably be optimized (both code-wize and using proc datasets rather than a datastep), but it represents one way of accomplishing such renames:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* create a sample dataset */&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain f1-f250 (250*1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Build a renames macro variable */&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when input(substr(name,2),8.) &amp;lt; 27 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name||"="||byte(input(substr(name,2),8.)+64)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when mod(input(substr(name,2),8.),26) eq 0 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name||"="||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte(floor((input(substr(name,2),8.)-1)/26)+64)||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte(26+64)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&amp;nbsp; name||"="||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte(floor((input(substr(name,2),8.)-1)/26)+64)||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte(mod(input(substr(name,2),8.),26)+64)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :renames separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname="WORK" and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; memname="HAVE"&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Rename the variables */&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have (rename=(&amp;amp;renames.));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jan 2012 14:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31688#M6084</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-18T14:41:17Z</dc:date>
    </item>
    <item>
      <title>How can I get excel column names as sas dataset variable names?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31689#M6085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Dear Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very very much!!! This is exactly what I want. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jan 2012 15:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31689#M6085</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-01-18T15:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31690#M6086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a similar issue with getnames. I have to append the csv files to data sets on daily basis. I have a macro to do this using proc import. Works fine as of now. Strangely, Some of the files have&amp;nbsp; column headers at the end of the csv (only for few days). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know if there is a way to read the column headers at the end of the files(dynamically, either first row of the file or last row of the file). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know we can do this using infile, by creating my own variables. But, using infile, my code will be very lengthy, and I wont be able to use a macro (as each file structure is different). I need this to read only few files. Usually the column headers will be in the firstrow itself. Thans for your help in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code for import step only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc import datafile=csvTest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out= work.&amp;amp;csvfile /*&amp;amp;libto..&amp;amp;csvfile*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbms = csv replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delimiter= ",";&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mixed=yes ;*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getnames=yes;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Mar 2012 22:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31690#M6086</guid>
      <dc:creator>jeeth79usa</dc:creator>
      <dc:date>2012-03-25T22:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31691#M6087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is no such option for CSV engine.&lt;/P&gt;&lt;P&gt;But For XLS engine there is an option namerow= to define which row contains variable names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="6" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR valign="top"&gt;&lt;TD width="11%"&gt;Data Source&lt;/TD&gt;&lt;TD width="22%"&gt;Syntax&lt;/TD&gt;&lt;TD width="16%"&gt;Valid Value&lt;/TD&gt;&lt;TD width="18%"&gt;Default Value&lt;/TD&gt;&lt;TD width="15%"&gt;In PROC IMPORT?&lt;/TD&gt;&lt;TD width="15%"&gt;In PROC EXPORT?&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD rowspan="11" width="11%"&gt;XLS&lt;/TD&gt;&lt;TD width="22%"&gt;ENDCOL&lt;/TD&gt;&lt;TD width="16%"&gt;Last column for data&lt;/TD&gt;&lt;TD width="18%"&gt;Last column that contains data&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;ENDNAMEROW&lt;/TD&gt;&lt;TD width="16%"&gt;Last row for variable names&lt;/TD&gt;&lt;TD width="18%"&gt;Same as NAMEROW&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;ENDROW&lt;/TD&gt;&lt;TD width="16%"&gt;Last row for data&lt;/TD&gt;&lt;TD width="18%"&gt;Last row that contains data&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;GETNAMES&lt;/TD&gt;&lt;TD width="16%"&gt;Yes|No&lt;/TD&gt;&lt;TD width="18%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;NAMEROW&lt;/TD&gt;&lt;TD width="16%"&gt;First row for variable names&lt;/TD&gt;&lt;TD width="18%"&gt;First row that contains variable names&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;NEWFILE&lt;/TD&gt;&lt;TD width="16%"&gt;Yes|No&lt;/TD&gt;&lt;TD width="18%"&gt;No&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;PUTNAMES&lt;/TD&gt;&lt;TD width="16%"&gt;Yes|No&lt;/TD&gt;&lt;TD width="18%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;RANGE&lt;/TD&gt;&lt;TD width="16%"&gt;NAME | SHEET$UL:LR&lt;/TD&gt;&lt;TD width="18%"&gt;First row&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;SHEET&lt;/TD&gt;&lt;TD width="16%"&gt;Sheet name&lt;/TD&gt;&lt;TD width="18%"&gt;First sheet&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;STARTCOL&lt;/TD&gt;&lt;TD width="16%"&gt;First column for data&lt;/TD&gt;&lt;TD width="18%"&gt;Last column that contains data&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR valign="top"&gt;&lt;TD width="22%"&gt;STARTROW&lt;/TD&gt;&lt;TD width="16%"&gt;First row for data&lt;/TD&gt;&lt;TD width="18%"&gt;First row that contains data&lt;/TD&gt;&lt;TD width="15%"&gt;Yes&lt;/TD&gt;&lt;TD width="15%"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Mar 2012 08:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31691#M6087</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-03-27T08:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31692#M6088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for the information. Unfortunaly, I have to deal with CSV engine for now. I will defenitely keep the XLS option in the future.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I was told that there is a way to get the names from the csv files dynamically whether they are in the first row or the last row(column positions may change in the future), using _infile_ i.e. by reading the columns header line &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was planning to do something like this in 2 steps. Please let me know if you can provide an example for me or if you can let me know if I am dping it correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename readcsv path; /*for unix envt*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 'ID' then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if index(_infile_, 'readcsv') then do;&lt;/P&gt;&lt;P&gt;call symput(fountit,_N_);&lt;/P&gt;&lt;P&gt;call symput("inputstatement",trim(_infile_));&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input &amp;amp;inputstatement;&lt;/P&gt;&lt;P&gt;if _n_ = &amp;amp;fountit then delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 02:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31692#M6088</guid>
      <dc:creator>jeeth79usa</dc:creator>
      <dc:date>2012-03-28T02:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31693#M6089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is code to input use PROC IMPORT and skip the first line with the column names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;proc import out=test file=tmpfile1 dbms=dlm replace ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; delimiter=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp; datarow=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; getnames=No;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is code to read the names from the first row and generate LABEL statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;filename rename temp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile tmpfile1 truncover dlm=',' dsd ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; file rename ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length label $256 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do var=1 by 1 until (label=' ');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input label @;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if label=' ' then stop;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put 'label var' var '=' label : $quote. ';';&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of using PROC DATASETS to apply the labels.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&lt;SPAN style="font-family: monospace; white-space: pre; background-color: #ffffff; color: #000000;"&gt;proc datasets lib=work nolist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; modify test;&lt;/P&gt;&lt;P&gt;%inc rename ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if you want the variables names to be A to Z, AA to AZ, ... like Excel column names then you could generate rename statments to rename VAR1 to A, VAR2 to B, .... VAR27 to AA, etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 05:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31693#M6089</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-28T05:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31694#M6090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you are doing is to judge which row is a name row.&lt;/P&gt;&lt;P&gt;But I need a sample file or sample data to test. What data you have ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 06:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31694#M6090</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-03-28T06:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31695#M6091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have several csv files all of them with dirrefent names, and files structure.&lt;/P&gt;&lt;P&gt;Proc import will not work in my case as some files have date_time in charectar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the files have date_time and id as common variable. In the future new columns may be added very rarely.&lt;/P&gt;&lt;P&gt;after reading the files, as id is numeric, I am getting missing value. So, I am removing by saying if id = . then delete;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know how read the name row dynamically, wheather names are first or last row. read the row before bringing the data to SAS, and append the names based on comma dlm to the records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;date_time,id,address,abcdef,aeiou,test&lt;/P&gt;&lt;P&gt;2012-02-01 12:34:55,1234,jkhuc,uhibddeiui,iouyefbyj&lt;/P&gt;&lt;P&gt;2012-03-12 12:34:55,1234,jfccuc,uhibweddsiui,iouyffbyj&lt;/P&gt;&lt;P&gt;2012-02-12 12:34:55,1234,jkxehuc,uhibiui,iouybyj&lt;/P&gt;&lt;P&gt;2012-01-11 12:34:55,1234,jkhdduc,uhibideui,iouyfrbyj&lt;/P&gt;&lt;P&gt;2012-01-22 12:34:55,1234,jkhqqduc,uhiefbiui,ioudfgybyj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 14:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31695#M6091</guid>
      <dc:creator>jeeth79usa</dc:creator>
      <dc:date>2012-03-28T14:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31696#M6092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not sure what you mean. If your files are in random formats then PROC IMPORT is your friend. Otherwise you will need to spend time for each file deciding how many variables it has, the names of the variables, the type and length of the variables.&amp;nbsp; PROC IMPORT will do that for you and get it right well over 80% of the time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if you want to take a CSV file like your example and write a program to read it here are the steps I do.&lt;/P&gt;&lt;P&gt;1) Copy the row with the variable names into my program.&amp;nbsp; Remove the commas prefix with INPUT and add formats based on what I think the type of the variable.&lt;/P&gt;&lt;P&gt;2) Insert the INPUT statement into a data step like this one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile 'new.txt' dsd dlm=',' truncover firstobs=2 lrecl=10000 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input .... ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) For some variables you might need to also add FORMAT and INFORMAT statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the data step for the example data you posted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'new.txt' dsd dlm=',' truncover firstobs=2 lrecl=10000 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; informat date_time anydtdtm.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format date_time datetime.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length address $100 abcdef aeiou test $20 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input date_time id address abcdef aeiou test ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 18:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31696#M6092</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-28T18:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31697#M6093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a bunch for both your responses. Sorry if I was not clear with my Q. Actually I did use proc import, and it did work for ~ 75% of the files(in my case). I have used the following macro to read the names dynamically. some files have the column headers at the EOF, instead of first row. This is the reason I was looking for an example to read the variable names dynamically regardless of top or bottom row, based on a common variable in all the files(in my case ID and date_time ). I have found a similar post in the blog, and I just have accommodate my variable name, read the entire column header, and use the _infile_ to read them dynamically so that I can accommodate the changes in the file structure in future. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://communities.sas.com/message/13449#13449"&gt;https://communities.sas.com/message/13449#13449&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mycode:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let path = "/sasdata/path/";&lt;/P&gt;&lt;P&gt;%let libto = library;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;%macro Readcsv (csvfile=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let foundit = %sysfunc(exist(&amp;amp;path.&amp;amp;csvfile..csv)); &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %if &amp;amp;foundit %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filename csvTest "&amp;amp;path.&amp;amp;csvfile..csv";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile csvTest;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _N_ eq 2 then do;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("hasRows", "yes");*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc import datafile=&amp;amp;path.&amp;amp;csvfile..csv &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=&amp;amp;libto..&amp;amp;csvfile replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delimiter= ",";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getnames=yes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scan=yes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mixed=yes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp; %end;*/&lt;/P&gt;&lt;P&gt;%mend Readcsv;&lt;/P&gt;&lt;P&gt;%Readcsv (csvfile= file_xyz);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Readcsv (csvfile= file_abc);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are some charecter constraints to deal with using proc import, and that is why I am reading the files using infile, and defining their lengths, formats and informats. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 19:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31697#M6093</guid>
      <dc:creator>jeeth79usa</dc:creator>
      <dc:date>2012-03-28T19:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get excel column names as sas dataset variable names? if the column names are at the end of files??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31698#M6094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you could code something like :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
filename x 'c:\x.csv';
data _null_;
infile x ;
input&amp;nbsp; date ?? yymmdd10. ; 
 if missing(date) then do;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_ eq 1 then call symputx('start',_infile_);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else call symputx('end',_infile_);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
run;
%put start=&amp;amp;start end=&amp;amp;end;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Mar 2012 05:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-excel-column-names-as-sas-dataset-variable-names/m-p/31698#M6094</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-03-29T05:57:12Z</dc:date>
    </item>
  </channel>
</rss>

