<?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 Stack datasets on top of each other in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495728#M31928</link>
    <description>&lt;P&gt;Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 102 datasets which I would like to stack on top of each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They are all in the same location and they have a name such as this;&lt;/P&gt;&lt;P&gt;For the first one;&lt;/P&gt;&lt;P&gt;esfs0004_prt2010m01.sas7bdat&lt;/P&gt;&lt;P&gt;esfs0004_prt2018m07.sas7bdat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to set up a macro which will iterate just all datasets first, creating a variable called month which would equal "2010m01" for any observation in the dataset&amp;nbsp;&lt;SPAN&gt;esfs0004_prt2010m01.sas7bdat and would be "2018M07" for any observation in dataset&amp;nbsp;esfs0004_prt2018m07.sas7bdat. When this is done, I would like to create a new dataset which has all the observations stacked on each other.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sny input would be most welcome.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sean&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Sep 2018 15:19:16 GMT</pubDate>
    <dc:creator>Sean_OConnor</dc:creator>
    <dc:date>2018-09-14T15:19:16Z</dc:date>
    <item>
      <title>Stack datasets on top of each other</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495728#M31928</link>
      <description>&lt;P&gt;Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 102 datasets which I would like to stack on top of each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They are all in the same location and they have a name such as this;&lt;/P&gt;&lt;P&gt;For the first one;&lt;/P&gt;&lt;P&gt;esfs0004_prt2010m01.sas7bdat&lt;/P&gt;&lt;P&gt;esfs0004_prt2018m07.sas7bdat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to set up a macro which will iterate just all datasets first, creating a variable called month which would equal "2010m01" for any observation in the dataset&amp;nbsp;&lt;SPAN&gt;esfs0004_prt2010m01.sas7bdat and would be "2018M07" for any observation in dataset&amp;nbsp;esfs0004_prt2018m07.sas7bdat. When this is done, I would like to create a new dataset which has all the observations stacked on each other.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sny input would be most welcome.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sean&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495728#M31928</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2018-09-14T15:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stack datasets on top of each other</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495734#M31929</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116786"&gt;@Sean_OConnor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 102 datasets which I would like to stack on top of each other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They are all in the same location and they have a name such as this;&lt;/P&gt;
&lt;P&gt;For the first one;&lt;/P&gt;
&lt;P&gt;esfs0004_prt2010m01.sas7bdat&lt;/P&gt;
&lt;P&gt;esfs0004_prt2018m07.sas7bdat&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to set up a macro which will iterate just all datasets first, creating a variable called month which would equal "2010m01" for any observation in the dataset&amp;nbsp;&lt;SPAN&gt;esfs0004_prt2010m01.sas7bdat and would be "2018M07" for any observation in dataset&amp;nbsp;esfs0004_prt2018m07.sas7bdat. When this is done, I would like to create a new dataset which has all the observations stacked on each other.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sny input would be most welcome.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sean&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

set libname.esfs004: indsname = source;
dsn=source;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You don't need a macro. See the solution above. The name will partially be in DSN variable though you'll need to extract it from the data set name using string functions I'll leave that as a step for you. If you're having issues please feel free to post back with details.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495734#M31929</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-14T15:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Stack datasets on top of each other</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495737#M31930</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to this so having some issues;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example of what I'm trying and the following error message;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname a "workfolder";

data want;

set a.esfs004: indsname = source;
dsn=source;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR&lt;BR /&gt;24 &lt;BR /&gt;25 GOPTIONS ACCESSIBLE;&lt;BR /&gt;26 data want;&lt;BR /&gt;27 &lt;BR /&gt;28 set a.esfs004: indsname = source;&lt;BR /&gt;ERROR: The data set list (A.esfs004:) does not contain any members.&lt;BR /&gt;29 dsn=source;&lt;BR /&gt;30 &lt;BR /&gt;31 run;&lt;BR /&gt;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:28:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495737#M31930</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2018-09-14T15:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Stack datasets on top of each other</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495740#M31931</link>
      <description>It’s saying the library is empty? What does it look like to you? It’s possible it’s case sensitive but it’s rare that would be the issue. Post your full code and log please.</description>
      <pubDate>Fri, 14 Sep 2018 15:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495740#M31931</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-14T15:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Stack datasets on top of each other</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495745#M31932</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116786"&gt;@Sean_OConnor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 102 datasets which I would like to stack on top of each other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They are all in the same location and they have a name such as this;&lt;/P&gt;
&lt;P&gt;For the first one;&lt;/P&gt;
&lt;P&gt;esfs0004_prt2010m01.sas7bdat&lt;/P&gt;
&lt;P&gt;esfs0004_prt2018m07.sas7bdat&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to set up a macro which will iterate just all datasets first, creating a variable called month which would equal "2010m01" for any observation in the dataset&amp;nbsp;&lt;SPAN&gt;esfs0004_prt2010m01.sas7bdat and would be "2018M07" for any observation in dataset&amp;nbsp;esfs0004_prt2018m07.sas7bdat. When this is done, I would like to create a new dataset which has all the observations stacked on each other.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sny input would be most welcome.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sean&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You would be better off creating an actual date value using year and month as between formats and date functions there are many ways to manipulate or use the date value. If you have a character variable like "2018M07" then you have would essentially have to create a date value if want to select records between, for example, June 2017 and Feb 2018, for any purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   string= '2018M07';
   date = input(strip(compress(string,'M')),yymmn6.);
   put date=date9. date=yymm. date=yymmn.;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495745#M31932</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-14T15:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Stack datasets on top of each other</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495797#M31936</link>
      <description>&lt;P&gt;Here is a sample program that may do what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* sample data */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data esfs0004_prt2010m01;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;1 2&lt;BR /&gt;3 4&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data esfs0004_prt2018m07;&lt;BR /&gt;input x y;&lt;BR /&gt;cards;&lt;BR /&gt;5 6&lt;BR /&gt;7 8&lt;BR /&gt;9 0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* create macro variables for the count of data set names in the library,&lt;BR /&gt;a list of the data set names to use when stacking the tables, and&lt;BR /&gt;each data set name in a separate macro variable */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT COUNT(MEMNAME) INTO :CNT FROM DICTIONARY.TABLES WHERE LIBNAME EQ 'WORK';&lt;BR /&gt; SELECT DISTINCT(MEMNAME) INTO :MEMLIST SEPARATED BY ' '&lt;BR /&gt; FROM DICTIONARY.TABLES WHERE LIBNAME EQ 'WORK'; &lt;BR /&gt; select DISTINCT(MEMNAME) into :v1 - :v%trim(&amp;amp;cnt) &lt;BR /&gt; from DICTIONARY.TABLES WHERE LIBNAME EQ 'WORK';&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* add the new variable to each individual data set */&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro addvar;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Do i=1 %to &amp;amp;cnt;&lt;/P&gt;
&lt;P&gt;Data &amp;amp;&amp;amp;&amp;amp;v&amp;amp;i;&lt;BR /&gt;set &amp;amp;&amp;amp;&amp;amp;v&amp;amp;i;&lt;BR /&gt;date=substr("&amp;amp;&amp;amp;&amp;amp;v&amp;amp;i",13);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%addvar;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* append (stack) all the data sets into one */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data final;&lt;BR /&gt;set &amp;amp;memlist;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 18:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Stack-datasets-on-top-of-each-other/m-p/495797#M31936</guid>
      <dc:creator>jebjur</dc:creator>
      <dc:date>2018-09-14T18:29:41Z</dc:date>
    </item>
  </channel>
</rss>

