<?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: How to create mutiple data set from multiple libref? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774563#M246200</link>
    <description>&lt;P&gt;This:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Libname xl1 xlsx "C:\Users\Desktop";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can't work. XLSX LIBNAMEs need to point to &lt;EM&gt;files&lt;/EM&gt;, not directories.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 16:26:01 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-10-15T16:26:01Z</dc:date>
    <item>
      <title>How to create mutiple data set from multiple libref?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774513#M246180</link>
      <description>&lt;P&gt;I am new at SAS. I would like to know if the following action is doable. I have two libref. Could I set two libref in a single dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So instead of doing this.&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;Libname xl1 xlsx "C:\Users\Desktop";
Libname xl2 xlsx "C:\Users\Desktop";

data report1;
	set xl1.sheet1;
run;

data report2;
	set xl2.sheet1;
run;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Could I do something like this?&lt;/P&gt;&lt;PRE&gt;data report1 report2;&lt;BR /&gt;set xl1.sheet1;&lt;BR /&gt;set xl2.sheet1;&lt;BR /&gt;run;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 14:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774513#M246180</guid>
      <dc:creator>marathoner</dc:creator>
      <dc:date>2021-10-15T14:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create mutiple data set from multiple libref?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774518#M246181</link>
      <description>&lt;P&gt;Yes, you CAN do this but it seems relatively pointless. First, you need only one LIBNAME statement, instead of referring to the same library (Excel file) twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, if you want to perform a SET, you should do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set dataset1 dataset2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;rather than two SET statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But essentially, the way you have programmed it, REPORT1 and REPORT2 are identical data sets, and as I said, this is kind of pointless as far as I can see. What are you trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 15:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774518#M246181</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-15T15:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create mutiple data set from multiple libref?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774519#M246182</link>
      <description>No but there are other ways. What are you actually trying to do overall?&lt;BR /&gt;&lt;BR /&gt;You can use PROC DATASETS/COPY to copy data sets from libraries to work or a different location as needed.</description>
      <pubDate>Fri, 15 Oct 2021 15:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774519#M246182</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-15T15:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create mutiple data set from multiple libref?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774529#M246187</link>
      <description>&lt;P&gt;You use as many input dataset into your data step as you need.&lt;/P&gt;
&lt;P&gt;It you want to concatenate the data (they have the same variables but represent different observations) then just list them on the SET statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set lib1.ds1 lib2.ds2 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to merge them (that is add new variables to the same observations based on some key variables that indicate which observations to combine) then use MERGE and BY statements.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge lib1.ds1 lib2.ds2 ;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also write multiple datasets in one data step.&amp;nbsp; Just list the names on the DATA statement and then use explicit OUTPUT statements to direct the observations to the appropriate dataset(s).&amp;nbsp; For example you migth want to generate three datasets from a merge, one with the observations that appear in both source datasets and then onse with the observations that appear in only one of the two.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data only1 only2 both;
  merge lib1.ds1(in=in1) lib2.ds2(in=in2);
  by id;
  if in1 and in2 then output both;
  else if in1 then output only1;
  else output only2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS: Note that your LIBNAME statement syntax is incorrect. If you are using the XLSX engine the path has to include a filename, not a directory name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Libname xl1 xlsx "C:\Users\Desktop\xl1.xlsx";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Oct 2021 15:14:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774529#M246187</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-15T15:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to create mutiple data set from multiple libref?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774531#M246188</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381632"&gt;@marathoner&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So instead of doing this.&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;Libname xl1 xlsx "C:\Users\Desktop";
Libname xl2 xlsx "C:\Users\Desktop";
&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding, in my opinion, this is a particularly poor place to store data.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 15:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774531#M246188</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-15T15:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create mutiple data set from multiple libref?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774563#M246200</link>
      <description>&lt;P&gt;This:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Libname xl1 xlsx "C:\Users\Desktop";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can't work. XLSX LIBNAMEs need to point to &lt;EM&gt;files&lt;/EM&gt;, not directories.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 16:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774563#M246200</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-15T16:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create mutiple data set from multiple libref?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774585#M246205</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381632"&gt;@marathoner&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am new at SAS. I would like to know if the following action is doable. I have two libref. Could I set two libref in a single dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Could I do something like this?&lt;/P&gt;
&lt;PRE&gt;data report1 report2;&lt;BR /&gt;set xl1.sheet1;&lt;BR /&gt;set xl2.sheet1;&lt;BR /&gt;run;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try it and see. I might suggest starting with two small data sets with different numbers of records to see the behavior more easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With data starting in EXCEL your attempt might fail because different identically named columns have different data types, which is why recommend using SAS data sets to experiment with.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 17:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-mutiple-data-set-from-multiple-libref/m-p/774585#M246205</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-15T17:58:59Z</dc:date>
    </item>
  </channel>
</rss>

