<?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: How to import data in Excel file with heading and variables names in first and second rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307292#M65787</link>
    <description>&lt;P&gt;Also try range:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import ..........
range='Sheet1$A2:D100'
&amp;nbsp;
range='A2:D100'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Oct 2016 03:03:39 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-10-26T03:03:39Z</dc:date>
    <item>
      <title>How to import data in Excel file with heading and variables names in first and second rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307177#M65755</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Excel file , the first row contains header and second row contains variable names. From third row data starts. I need to read variable names and data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code getting the header in &amp;nbsp;the first variable name column and variable names appear in first row of data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;excel data;&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; A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B &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;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;HEADER NAME HEADERNAME&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; FILE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TERM &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LLT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HLT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PT&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; EVENT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ANEMIA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OUTPUT GETTING;&lt;/P&gt;&lt;P&gt;HEADER NAME HEADERNAME &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D &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;E &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILE &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; &amp;nbsp; TERM &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LLT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HLT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EVENT &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; ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ANEMIA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OUTPUT NEEDED;&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; FILE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;TERM &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LLT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HLT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PT&lt;/SPAN&gt; &amp;nbsp;&amp;nbsp;&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; EVENT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ANEMIA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ANEMIA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc import datafile="C:\Users\aa\Desktop\one.xlsx" DBMS=xlsx out=co;datarow=2;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 16:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307177#M65755</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-10-25T16:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to import data in Excel file with heading and variables names in first and second rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307231#M65772</link>
      <description>&lt;P&gt;Have you tried with datarow=3 ?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 19:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307231#M65772</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-25T19:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to import data in Excel file with heading and variables names in first and second rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307270#M65780</link>
      <description>&lt;P&gt;Yes I tried. But I am not getting the variable names. How to get the variable names. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 00:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307270#M65780</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-10-26T00:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to import data in Excel file with heading and variables names in first and second rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307292#M65787</link>
      <description>&lt;P&gt;Also try range:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import ..........
range='Sheet1$A2:D100'
&amp;nbsp;
range='A2:D100'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 03:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307292#M65787</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-26T03:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to import data in Excel file with heading and variables names in first and second rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307424#M65838</link>
      <description>&lt;P&gt;I am going to assume that your "header" row contains more detailed information about the variable. Such as header "Value at purchase" or some thing longer and that the variable name, which might be VP is the preferred name of the variable for datasets and such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that is the case here is what I would do (and have done MANY times).&lt;/P&gt;
&lt;P&gt;1) Cut the header row and paste into another spreadsheet to save it. It actually makes sense to post transposed.&lt;/P&gt;
&lt;P&gt;2) Import the data set without the header row. The VARIABLE names will be from row 1(since the header has been removed)&lt;/P&gt;
&lt;P&gt;3) You can use proc data sets and the information in the saved header to row to create LABELS that SAS will display for most purposes in stead of the variable Name.&lt;/P&gt;
&lt;P&gt;The Proc Datasets code would look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Datasets library=mylib; /* mylib being the library the data set was saved to. possibly WORK from your example*/&lt;/P&gt;
&lt;P&gt;Modify co;&amp;nbsp; /* the name of the data set*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; label&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1 = "heading 1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var2 = "heading 2"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* continue till all of the variables are accounted for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that by also copy and paste transpose of both the header row and variable you would have columns and could use Excel functions to create text like Var="heading 1" that you could copy and paste out of Excel into the code for the label statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This particular operation actuall accounts for about 10 to 15% of my actual data manipulation in Excel&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 14:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/307424#M65838</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-26T14:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to import data in Excel file with heading and variables names in first and second rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/645526#M192997</link>
      <description>&lt;P&gt;As you do not always know the width and length of your data, you can also use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;range='Sheet1$A2:'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 07:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-data-in-Excel-file-with-heading-and-variables/m-p/645526#M192997</guid>
      <dc:creator>Aldert</dc:creator>
      <dc:date>2020-05-06T07:11:27Z</dc:date>
    </item>
  </channel>
</rss>

