<?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: Appending files using loop over a list in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Appending-files-using-loop-over-a-list/m-p/943807#M369881</link>
    <description>&lt;P&gt;Have you verified that all the data sets you are thinking of using have the same variables? And that the variables are all of the same type and length?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ask because the properties of the data may limit how you "append" data. And if the variables of the same name have different lengths additional steps may be needed to prevent loss of data. We have many cases of new users assuming their data is the same and finding out when they go to combine data sets that there are problems that will prevent any sort of appending.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your problem is as as simple as you state you may just need a single macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let listvar = A202401  A202303 A202308;

Data want;
   set &amp;amp;listvar;
run;&lt;/PRE&gt;
&lt;P&gt;By same location I would expect in SAS terms that you have assigned a library to point to that location. Then the listvar above would have the datasets as libref.name instead of just the name.&lt;/P&gt;
&lt;PRE&gt;libname mylib "&amp;lt;path&amp;gt;";

%let listvar = mylib.A202401 mylib.A202303 mylib.A202308;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Sep 2024 14:10:41 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-09-13T14:10:41Z</dc:date>
    <item>
      <title>Appending files using loop over a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-files-using-loop-over-a-list/m-p/943783#M369878</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I have files named as A202401, A202402, A202303, A202301 and so on at same location. But I need any 3 files.&lt;BR /&gt;I want to create a macro which will help me to append all data sets into single sas data set. I want to store the files names in a list and then loop over the list to append files.&lt;BR /&gt;Your help is much appreciated.</description>
      <pubDate>Fri, 13 Sep 2024 13:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-files-using-loop-over-a-list/m-p/943783#M369878</guid>
      <dc:creator>Raunak1</dc:creator>
      <dc:date>2024-09-13T13:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Appending files using loop over a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-files-using-loop-over-a-list/m-p/943786#M369879</link>
      <description>&lt;P&gt;If these are the only file names that begin with "A2024" then the task is easy and does not require macros.&amp;nbsp; For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set A2024: indsname = month;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If some version of MONTH is already part of each data set,&amp;nbsp; you can skip the INDSNAME option.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 13:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-files-using-loop-over-a-list/m-p/943786#M369879</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-09-13T13:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Appending files using loop over a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-files-using-loop-over-a-list/m-p/943807#M369881</link>
      <description>&lt;P&gt;Have you verified that all the data sets you are thinking of using have the same variables? And that the variables are all of the same type and length?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ask because the properties of the data may limit how you "append" data. And if the variables of the same name have different lengths additional steps may be needed to prevent loss of data. We have many cases of new users assuming their data is the same and finding out when they go to combine data sets that there are problems that will prevent any sort of appending.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your problem is as as simple as you state you may just need a single macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let listvar = A202401  A202303 A202308;

Data want;
   set &amp;amp;listvar;
run;&lt;/PRE&gt;
&lt;P&gt;By same location I would expect in SAS terms that you have assigned a library to point to that location. Then the listvar above would have the datasets as libref.name instead of just the name.&lt;/P&gt;
&lt;PRE&gt;libname mylib "&amp;lt;path&amp;gt;";

%let listvar = mylib.A202401 mylib.A202303 mylib.A202308;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2024 14:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-files-using-loop-over-a-list/m-p/943807#M369881</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-13T14:10:41Z</dc:date>
    </item>
  </channel>
</rss>

