<?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: Combining data sets into one temporary data set. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435097#M281995</link>
    <description>&lt;P&gt;If you haven't used a naming convention you need to explicitly list all the data sets.&amp;nbsp; Try the following to import all at once:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data import_all;
 
*make sure variables to store file name are long enough;
length filename txt_file_name $256;
length Customer 8 Date1 8 Date2 8 Address $24;
 
*keep file name from record to record;
retain txt_file_name;
 
*Use wildcard in input;
infile '/home/jadencarlson0/STAT-725/Homework 3/*.txt' firstobs=2 eov=eov filename=filename truncover;
 
*Input first record and hold line;
input@;
 
*Check if this is the first record or the first record in a new file;
*If it is, replace the filename with the new file name and move to next line;
if _n_ eq 1 or eov then do;
txt_file_name = scan(filename, -1, "\");
eov=0;
end;
 
*Otherwise  go to the import step and read the files;
else input Customer Date1 : YYMMDD10. Date2 : YYMMDD10. Address $ &amp;amp;;
 
City=scan(address,1,',');
ZipCode=input(strip(scan(address,-1,',')),5.);
keep Customer Date1 Date2 City ZipCode;

;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Feb 2018 22:19:48 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-07T22:19:48Z</dc:date>
    <item>
      <title>Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435058#M281985</link>
      <description>&lt;P&gt;I am having trouble combining four data sets that came from .txt files on my computer into one new temporary data set. I have attached the four .txt files. The SAS code I have used is below. The first 4 data steps are for reading the files into SAS; then I sorted the data sets by Customer, and then tried to merge. But when I merged them I only got the 25 observations from the AgentD data set. Any ideas on how to get all four of them into one set (like one on top of the next)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data AgentA;
infile '/home/jadencarlson0/STAT-725/Homework 3/AgentA.txt' firstobs=2;
length Customer 8 Date1 8 Date2 8 City $24 ZipCode 8;
input Customer Date1 : YYMMDD10. Date2 : YYMMDD10. City $ &amp;amp; ZipCode;
format Date1 Date2 YYMMDD10.;
run;
proc print data=AgentA;
title 'AgentA';
run;

data AgentB;
infile '/home/jadencarlson0/STAT-725/Homework 3/AgentB.txt' firstobs=2;
length Customer 8 Date1 8 Date2 8 City $24 ZipCode 8;
input Customer Date1 : YYMMDD10. Date2 : YYMMDD10. City $ &amp;amp; Zipcode;
format Date1 Date2 YYMMDD10.;
run;
proc print data=AgentB;
title 'AgentB';
run;

data AgentC;
infile '/home/jadencarlson0/STAT-725/Homework 3/AgentC.txt' firstobs=2;
length Customer 8 Date1 8 Date2 8 City $24 ZipCode 8;
input Customer Date1 : YYMMDD10. Date2 : YYMMDD10. City $ &amp;amp; Zipcode;
format Date1 Date2 YYMMDD10.;
run;
proc print data=AgentC;
title 'AgentC';
run;

data AgentD;
infile '/home/jadencarlson0/STAT-725/Homework 3/AgentD.txt' firstobs=2;
length Customer 8 Date1 8 Date2 8 Address $24;
input Customer Date1 : YYMMDD10. Date2 : YYMMDD10. Address $ &amp;amp;;
format Date1 Date2 YYMMDD10.;
City=scan(address,1,',');
ZipCode=input(strip(scan(address,-1,',')),5.);
keep Customer Date1 Date2 City ZipCode;
run;
proc print data=agentd;
title 'AgentD';
run;

proc sort data=AgentA;
by Customer;
run;
proc sort data=AgentB;
by Customer;
run;
proc sort data=AgentC;
by Customer;
run;
proc sort data=AgentD;
by Customer;
run;
data Combined;
merge AgentA AgentB AgentC AgentD;
by Customer;&lt;BR /&gt;run;
proc print data=Combined;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Feb 2018 20:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435058#M281985</guid>
      <dc:creator>newbie_grad</dc:creator>
      <dc:date>2018-02-07T20:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435066#M281986</link>
      <description>&lt;P&gt;You shouldn't be merging. you should be appending. Try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data combined;&lt;/P&gt;&lt;P&gt;set agent:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 20:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435066#M281986</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-07T20:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435068#M281987</link>
      <description>&lt;P&gt;MERGE -&amp;gt; add columns to your data set&lt;/P&gt;
&lt;P&gt;APPEND -&amp;gt; add rows to your data set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you want rows.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 21:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435068#M281987</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-07T21:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435070#M281988</link>
      <description>&lt;P&gt;Set the 4 data sets together as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;suggests. The code set Agent: ; with the : says to use all data sets that start with Agent. If you have other sets that start with Agent then list the ones you want to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then sort by customer and possibly your date variables After combining them.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 21:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435070#M281988</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-07T21:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435081#M281989</link>
      <description>&lt;P&gt;That all worked. Now I need to make a new column titled 'Agent' for which Agent .txt file the data came from in this new combined data set. So the first 25 records would say A, the next B, the next C, and the final 25 would be labeled D.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Combined;
set Agent:;
run;
proc print data=Combined;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Feb 2018 21:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435081#M281989</guid>
      <dc:creator>newbie_grad</dc:creator>
      <dc:date>2018-02-07T21:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435083#M281990</link>
      <description>&lt;P&gt;look for indsname= in set statement option. im eatin my lunch now, cant type properlyto help&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 21:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435083#M281990</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-07T21:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435085#M281991</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Combined;
set Agent: indsname=source;
dsn=source;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also modify your initial read in program to read them all into the same file at once but I think this would solve your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 21:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435085#M281991</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-07T21:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435089#M281992</link>
      <description>&lt;P&gt;What if I just want it to say A, B, C, or D instead of WORK.AGENTA?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kl.jpg" style="width: 483px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18390i313DE292D21E7CDA/image-size/large?v=v2&amp;amp;px=999" role="button" title="kl.jpg" alt="kl.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Combined;
title 'Combined DataSet';
set Agent: indsname=source;
Agent=source;
run;
proc print data=Combined;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Feb 2018 22:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435089#M281992</guid>
      <dc:creator>newbie_grad</dc:creator>
      <dc:date>2018-02-07T22:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435090#M281993</link>
      <description>&lt;P&gt;lol you are being cheeky, aren't you ? hahaha&lt;/P&gt;&lt;P&gt;why did you name&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; AgentA&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
data AgentB; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in the first place?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 22:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435090#M281993</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-07T22:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435095#M281994</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;Haha! I'm just trying to make my professor happy! The current code makes sense to me, but I know I'm going to get points off. So I changed all my Data to&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data A;&lt;/P&gt;&lt;P&gt;Data B;&lt;/P&gt;&lt;P&gt;etc. like you suggested and it still came up with the same WORK.AGENTA in the columns...At this point, I'll probably just leave it, but I greatly appreciate&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; 's responses today. Literally couldn't have gotten through this without you both! Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 22:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435095#M281994</guid>
      <dc:creator>newbie_grad</dc:creator>
      <dc:date>2018-02-07T22:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435097#M281995</link>
      <description>&lt;P&gt;If you haven't used a naming convention you need to explicitly list all the data sets.&amp;nbsp; Try the following to import all at once:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data import_all;
 
*make sure variables to store file name are long enough;
length filename txt_file_name $256;
length Customer 8 Date1 8 Date2 8 Address $24;
 
*keep file name from record to record;
retain txt_file_name;
 
*Use wildcard in input;
infile '/home/jadencarlson0/STAT-725/Homework 3/*.txt' firstobs=2 eov=eov filename=filename truncover;
 
*Input first record and hold line;
input@;
 
*Check if this is the first record or the first record in a new file;
*If it is, replace the filename with the new file name and move to next line;
if _n_ eq 1 or eov then do;
txt_file_name = scan(filename, -1, "\");
eov=0;
end;
 
*Otherwise  go to the import step and read the files;
else input Customer Date1 : YYMMDD10. Date2 : YYMMDD10. Address $ &amp;amp;;
 
City=scan(address,1,',');
ZipCode=input(strip(scan(address,-1,',')),5.);
keep Customer Date1 Date2 City ZipCode;

;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Feb 2018 22:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435097#M281995</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-07T22:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435098#M281996</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190577"&gt;@newbie_grad&lt;/a&gt;&amp;nbsp;All the best mate!. This forum is very addictive. Try to get on here more often. I am off for my midterm exam at my college in an hour. I was so stressed but your post let go of my stess. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Take care&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 22:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435098#M281996</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-07T22:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data sets into one temporary data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435250#M281997</link>
      <description>&lt;P&gt;Merge also updates columns in dataset a with column values from dataset b.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 13:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-sets-into-one-temporary-data-set/m-p/435250#M281997</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-02-08T13:40:50Z</dc:date>
    </item>
  </channel>
</rss>

