<?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: Import variable names from excel and data for the same from notepad in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42540#M8712</link>
    <description>Sam.&lt;BR /&gt;
&lt;BR /&gt;
Please be more specific.&lt;BR /&gt;
&lt;BR /&gt;
What are you trying to do? Where is your data?&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
    <pubDate>Tue, 19 Jan 2010 14:19:54 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2010-01-19T14:19:54Z</dc:date>
    <item>
      <title>Import variable names from excel and data for the same from notepad</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42539#M8711</link>
      <description>Hi,&lt;BR /&gt;
How to import descriptor portion (Variables names ) from Excel and the corresponding data from text file .&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
Sam</description>
      <pubDate>Tue, 19 Jan 2010 12:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42539#M8711</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2010-01-19T12:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Import variable names from excel and data for the same from notepad</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42540#M8712</link>
      <description>Sam.&lt;BR /&gt;
&lt;BR /&gt;
Please be more specific.&lt;BR /&gt;
&lt;BR /&gt;
What are you trying to do? Where is your data?&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Tue, 19 Jan 2010 14:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42540#M8712</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2010-01-19T14:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Import variable names from excel and data for the same from notepad</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42541#M8713</link>
      <description>Well, yes.&lt;BR /&gt;
Use PROC IMPORT on your Excel-file, and then read your text-file with appropriate method, &lt;BR /&gt;
and PROC APPEND to table created by PROC IMPORT.&lt;BR /&gt;
/Linus</description>
      <pubDate>Tue, 19 Jan 2010 14:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42541#M8713</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2010-01-19T14:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Import variable names from excel and data for the same from notepad</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42542#M8714</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I am having variables in Excel sheet and the dataset was created and i have the data in txt file now i want to create the dataset with variables in excel and data in csv.&lt;BR /&gt;
&lt;BR /&gt;
Excel Variable:&lt;BR /&gt;
name  age&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data in Text.&lt;BR /&gt;
sas,23&lt;BR /&gt;
bi,45&lt;BR /&gt;
Nani,90&lt;BR /&gt;
kool,89&lt;BR /&gt;
&lt;BR /&gt;
output should be &lt;BR /&gt;
&lt;BR /&gt;
name  age&lt;BR /&gt;
sas     23&lt;BR /&gt;
bi        45&lt;BR /&gt;
Nani     90&lt;BR /&gt;
kool      89</description>
      <pubDate>Wed, 20 Jan 2010 05:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42542#M8714</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2010-01-20T05:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Import variable names from excel and data for the same from notepad</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42543#M8715</link>
      <description>OK.&lt;BR /&gt;
&lt;BR /&gt;
Then keeping it simple, I would go as Linus suggested.&lt;BR /&gt;
&lt;BR /&gt;
PROC IMPORT form EXCEL (be sure to load the first row as an header row)&lt;BR /&gt;
&lt;BR /&gt;
Then you could maybe load the table layout (var names) into a macro var list, say like this:&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
select NAME into :VARNAMES separated by ',' from DICTIONARY.COLUMNS&lt;BR /&gt;
where LIBNAME eq '&lt;LIBNAME-OF-THE-IMPORTED-TABLE&gt;
MEMNAME eq '&lt;NAME-OF-THE-IMPORTED-TABLE&gt;'&lt;BR /&gt;
order by NPOS;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
After that, and assuming your data file is not extensive, build a second data file with an header row and the concatenated data.&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
infile '&lt;YOUR-DATA-FILE&gt;';&lt;BR /&gt;
file '&lt;YOUR-SECOND-DATA-FILE&gt;';&lt;BR /&gt;
if _N_ eq 1 then put "&amp;amp;VARNAMES"; * put header row;&lt;BR /&gt;
input; * read one row;&lt;BR /&gt;
put _infile_; * write read buffer to second file;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Then PROC IMPORT the resulting second file, loading the first row as an header row.&lt;BR /&gt;
&lt;BR /&gt;
SAS will try to guess the size and type of each column from the first 20 rows (you can modify this number through the registry) in the file.&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/YOUR-SECOND-DATA-FILE&gt;&lt;/YOUR-DATA-FILE&gt;&lt;/NAME-OF-THE-IMPORTED-TABLE&gt;&lt;/LIBNAME-OF-THE-IMPORTED-TABLE&gt;</description>
      <pubDate>Wed, 20 Jan 2010 08:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42543#M8715</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2010-01-20T08:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Import variable names from excel and data for the same from notepad</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42544#M8716</link>
      <description>on a recent project, we got a bit - beyond simple - a lot more specific &lt;BR /&gt;
In the excel sheet metadata was maintained, providing name and type - as defined by storage length and/or informat. An optional format could be defined. The expected column header was also defined.&lt;BR /&gt;
The order of metadata was the output column order. &lt;BR /&gt;
A match between column header and "expected column header" was made. Unexpected columns would be "read" as $20. &lt;BR /&gt;
It was designed to be an iterative process to support new data. It was built because the delivered information had "creep" as the use of underlying data columns adapted and new columns were added. &lt;BR /&gt;
It overcame a few problems in the original "excel data collection".&lt;BR /&gt;
1 mixed type columns&lt;BR /&gt;
2 special missing values ( cells with symbols allied to special conditions instead of numbers)&lt;BR /&gt;
3 columns delivered don't always match the columns required list.&lt;BR /&gt;
The data was received as a formated excel sheet. It was "unformatted" (all columns given "format=text"). Then the data were saved from excel as a plain csv file. It is this csv file which is loaded subject to the rules of the metadata.&lt;BR /&gt;
While the metadata can be maintained in a "quality" that is easy and reliable for SAS to read from excel (with just a libname statement making the connection), the primary data received, were not able to be controlled in such a reliable way. Hence the elaborate import management.&lt;BR /&gt;
 &lt;BR /&gt;
Of course once we thought we had a reliable method for handling almost any data supplied, new complexities demonstrated its shortcomings:  sometimes column headers are not unique ("which metadata row should we choose?"); data sometimes needed more than one row of column header to define it.&lt;BR /&gt;
Basically, these problems are caused by data that does not conform to "standard csv" but that is the nature of "data in excel".&lt;BR /&gt;
At least "excel data" never causes a "problem of volume" &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Wed, 20 Jan 2010 13:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-variable-names-from-excel-and-data-for-the-same-from/m-p/42544#M8716</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-01-20T13:14:24Z</dc:date>
    </item>
  </channel>
</rss>

