<?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: Concatenate multiple sasfiles in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-sasfiles/m-p/842946#M333299</link>
    <description>&lt;P&gt;The main thing is to make sure the variables are defined consistently across the datasets.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How did you create the original datasets?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How did they end up with the&amp;nbsp;&lt;SPAN&gt;PATIENT_FIRST_NAME&amp;nbsp;and NOTES variables defined with different lengths in the different datasets?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use PROC CONTENTS to see the variable attributes.&amp;nbsp; The key things you need to check is the TYPE and the LENGTH.&amp;nbsp; &amp;nbsp;You definitely cannot combine datasets when the same variable is defined as different types in the two datasets.&amp;nbsp; If the LENGTH of characters variables are different then that is what it causing the message you are seeing.&amp;nbsp; You might also need to check the FORMATS (if any) that are attached to the variables.&amp;nbsp; Because if you fix the length of the character variable the values will store ok, but if you accidentally end up with a format that only display some of the characters in the variable then it will still cause you trouble down the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Nov 2022 19:04:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-07T19:04:17Z</dc:date>
    <item>
      <title>Concatenate multiple sasfiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-sasfiles/m-p/842928#M333296</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to concatenate multiple files from one single folder. I was getting some warning and would like to know how to resolve the problem. Thanks&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;libname a&amp;nbsp; "/_B/P4/PC/SASDC/idkey_2020_2021";&lt;/DIV&gt;&lt;DIV class=""&gt;data idkey_all;&lt;BR /&gt;set a.idkey_for_202011 a.idkey_for_202012 a.idkey_for_202101&lt;BR /&gt;a.idkey_for_202102 a.idkey_for_202103 a.idkey_for_202104;&lt;/DIV&gt;&lt;DIV class=""&gt;run;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;WARNING: Multiple lengths were specified for the variable PATIENT_FIRST_NAME by input data set(s). This can cause truncation of data.&lt;/DIV&gt;&lt;DIV class=""&gt;WARNING: Multiple lengths were specified for the variable NOTES by input data set(s). This can cause truncation of data.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 07 Nov 2022 17:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-sasfiles/m-p/842928#M333296</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2022-11-07T17:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple sasfiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-sasfiles/m-p/842946#M333299</link>
      <description>&lt;P&gt;The main thing is to make sure the variables are defined consistently across the datasets.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How did you create the original datasets?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How did they end up with the&amp;nbsp;&lt;SPAN&gt;PATIENT_FIRST_NAME&amp;nbsp;and NOTES variables defined with different lengths in the different datasets?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use PROC CONTENTS to see the variable attributes.&amp;nbsp; The key things you need to check is the TYPE and the LENGTH.&amp;nbsp; &amp;nbsp;You definitely cannot combine datasets when the same variable is defined as different types in the two datasets.&amp;nbsp; If the LENGTH of characters variables are different then that is what it causing the message you are seeing.&amp;nbsp; You might also need to check the FORMATS (if any) that are attached to the variables.&amp;nbsp; Because if you fix the length of the character variable the values will store ok, but if you accidentally end up with a format that only display some of the characters in the variable then it will still cause you trouble down the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 19:04:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-sasfiles/m-p/842946#M333299</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-07T19:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate multiple sasfiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-sasfiles/m-p/842952#M333303</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The proper solution is to follow &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s advice and get your input data sets om a common form before you append them.&lt;/P&gt;
&lt;P&gt;I suppose the data come from a monthly csv-file or something similar, and they are imported with a proc import, so the varaibles have their lengths depending on the current month's actual data. write uour own data steps instead, so you can control what's happening.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As your warnings say: The variables in your output get the length and attributes of the first dataset in the set statement, and longer names or notes in later datasets are truncated, so you get incomplete data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A quick and dirty solution - definitely not recommended for anything that isn't a one-shot, but ends up in a production job - is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname a  "/_B/P4/PC/SASDC/idkey_2020_2021";

data idkey_all;
  length PATIENT_FIRST_NAME $60 NOTES $512;
  format PATIENT_FIRST_NAME $60. NOTES $512.;
  set 
    a.idkey_for_202011 a.idkey_for_202012 a.idkey_for_202101
    a.idkey_for_202102 a.idkey_for_202103 a.idkey_for_202104;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The lengths should be set to (at least) the max. lengths in all monthly data sets. You have the correct length when the code runs without warnings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 19:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-sasfiles/m-p/842952#M333303</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2022-11-07T19:28:36Z</dc:date>
    </item>
  </channel>
</rss>

