<?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: Append multiple dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344617#M79207</link>
    <description>&lt;P&gt;we have 128 excel files in each file there are 20 variables?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2017 13:39:22 GMT</pubDate>
    <dc:creator>india2016</dc:creator>
    <dc:date>2017-03-27T13:39:22Z</dc:date>
    <item>
      <title>Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344558#M79189</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;base data set and append data set having different variable length and force option is not working.Is there any solution to get proper variable length?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 10:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344558#M79189</guid>
      <dc:creator>india2016</dc:creator>
      <dc:date>2017-03-27T10:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344573#M79195</link>
      <description>&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;select *&lt;/P&gt;
&lt;P&gt;&amp;nbsp; from one&amp;nbsp;&lt;/P&gt;
&lt;P&gt;union all corr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;select *&lt;/P&gt;
&lt;P&gt;&amp;nbsp; from two;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 11:07:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344573#M79195</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-27T11:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344587#M79199</link>
      <description>&lt;P&gt;What does not working mean?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 11:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344587#M79199</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-27T11:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344601#M79201</link>
      <description>&lt;P&gt;Book1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Gender&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;female&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;male&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Book2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Gender&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;female&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;transgender&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;male&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have this two datasets in excel format.After importing these two excel sheets I want to append book1 &amp;amp; book2.&lt;/P&gt;&lt;P&gt;If I use append table in SAS EG then I got &amp;nbsp;"transg" &amp;nbsp;which takes the length of "female" from book2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What should I do to get the right result?("transg" as transgender)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 13:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344601#M79201</guid>
      <dc:creator>india2016</dc:creator>
      <dc:date>2017-03-27T13:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344605#M79203</link>
      <description>&lt;P&gt;Set dataset 2 as the base and dataset 1 as the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally, make your base table with desired characteristics (length, type, format) first and use that in proc append.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 13:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344605#M79203</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-27T13:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344607#M79204</link>
      <description>but what if there are many tables and if we don't know characteristics?&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Mar 2017 13:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344607#M79204</guid>
      <dc:creator>india2016</dc:creator>
      <dc:date>2017-03-27T13:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344614#M79206</link>
      <description>&lt;P&gt;1. Compare all datasets and determine max length required using Dictionary tables. Create a Base dataset with these characteristics&amp;nbsp;that's empty to start.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Append using a data step or SQL union. You may still run into truncation issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Create Base data set with arbitrarily large lengths and truncate later.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest #1.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 13:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344614#M79206</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-27T13:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344617#M79207</link>
      <description>&lt;P&gt;we have 128 excel files in each file there are 20 variables?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 13:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344617#M79207</guid>
      <dc:creator>india2016</dc:creator>
      <dc:date>2017-03-27T13:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344664#M79223</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123179"&gt;@india2016&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;we have 128 excel files in each file there are 20 variables?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This tells me that you are likely using Proc Import or similar that lets EXCEL controll the reported lengths of variables.&lt;/P&gt;
&lt;P&gt;One approach if you know, or have a reasonable guess as to the lengths the values should take is to make a dummy set with the maximum length and append each one to that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data dummy;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; length var1 $ 25 var2 var3 $ 10 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;will create a data set with 3 variables with the lengths indicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I you have many data sets and the structures are the same you may want to use a SET statement to combine all of them at the same time:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set DUMMY&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; dataset1&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; datasetq&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; datasetabc;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you name the sets nicely you can even use a short cut list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set dummy dataset1 - dataset20;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 15:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344664#M79223</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-27T15:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344716#M79237</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Taking care to get the maximum length of a excel string before importing&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Taking care to get the maximum length of a excel string before importing

inspired by
https://goo.gl/fiZXXR
https://communities.sas.com/t5/Base-SAS-Programming/Append-multiple-dataset/m-p/344558

Issue
I have this two datasets in excel format.After importing these
two excel sheets I want to append book1 &amp;amp; book2.
If I use append table in SAS EG then I got  "transg"
which takes the length of "female" from book2.


You may sometimes get away without specifying character length, but it is
better to passthru and check the lengths. I suspect
odbc passthru may only support length upto 255 bytes.
No sure of OLE-DB. You ned to passthru for this issue?

HAVE ( two sheets in one workbook )
====================================


d:/xls/books.xlsx sheet BOOK1

    +------------------+
    |        A         |
    +------------------+
1   |      BOOK        |
    +------------------+
2   |     Gender       |
    +-------------------
3   |     female       |
    +-------------------
4   |      male        |
    +-------------------

[BOOK1]


d:/xls/books.xlsx sheet BOOK2

    +------------------+
    |        A         |
    +------------------+
1   |      BOOK        |
    +------------------+
2   |     Gender       |
    +-------------------
3   |     female       |
    +-------------------
4   |  transgender     |
    +-------------------
4   |      male        |
    +-------------------

[BOOK2]

WANT   (following SAS dataset )
================================

p to 40 obs from want total obs=7

bs    BOOK

1     Gender
2     female
3     male
4     Gender
5     female
6     transgender
7     male

WORKING CODE

      connect to excel (Path="d:\xls\books.xlsx");
      select max(len(book)) as lenmax

*                _                  _       _
 _ __ ___   __ _| | _____        __| | __ _| |_ __ _
| '_ ` _ \ / _` | |/ / _ \_____ / _` |/ _` | __/ _` |
| | | | | | (_| |   &amp;lt;  __/_____| (_| | (_| | || (_| |
|_| |_| |_|\__,_|_|\_\___|      \__,_|\__,_|\__\__,_|

;


%utlfkil(d:/xls/books.xlsx); * delete if exists;
libname xel "d:/xls/books.xlsx";

data xel.book1;
  informat book $11.;
  input Book ;
cards4;
Gender
female
male
;;;;
run;quit;


data xel.book2;
  informat book $11.;
  input Book ;
cards4;
Gender
female
transgender
male
;;;;
run;quit;

*          _       _   _
 ___  ___ | |_   _| |_(_) ___  _ __
/ __|/ _ \| | | | | __| |/ _ \| '_ \
\__ \ (_) | | |_| | |_| | (_) | | | |
|___/\___/|_|\__,_|\__|_|\___/|_| |_|

;

* notes
   you need bckslashes for this to work d:\xls\books.xlsx
   if uncomfortable with DOSUBL just pull the code out
   and run outside the datastep
;


%symdel maxlen;
libname xel "d:/xls/books.xlsx";
data want;

  if _n_=0 then do;
    %let rc=%sysfunc(dosubl(%nrbquote(
        proc sql dquote=ansi;
           connect to excel (Path="d:\xls\books.xlsx");
             select max(lenmax) into :maxlen separated by ' ' from connection to Excel
                 (
                  Select
                       max(len(book)) as lenmax
                  from
                       book1
                  union
                  select
                       max(len(book)) as lenmax
                  from
                       book2
                 );
             disconnect from Excel;
        quit;
        libname xel "d:/xls/books.xlsx";
        run;quit;
       )));
   end;

   set
     xel.book1(dbsastype=(book="char(&amp;amp;maxlen.)"))
     xel.book2(dbsastype=(book="char(&amp;amp;maxlen.)"))
   ;
run;quit;

libname xel clear;



                Variables in Creation Order

#    Variable    Type    Len    Format    Informat    Label

1    BOOK        Char     11    $6.       $6.         BOOK



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Mar 2017 18:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344716#M79237</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-27T18:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Append multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344719#M79239</link>
      <description>If you do not have named ranges book1, book2 use&lt;BR /&gt;'[shee1$]' within the passthru</description>
      <pubDate>Mon, 27 Mar 2017 18:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-multiple-dataset/m-p/344719#M79239</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-27T18:17:31Z</dc:date>
    </item>
  </channel>
</rss>

