<?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: merge data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/merge-data/m-p/29343#M6879</link>
    <description>data file1;&lt;BR /&gt;
input ID name$ add1$ ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 nikki mumbai&lt;BR /&gt;
2 pavan HYD&lt;BR /&gt;
3 prani chennai&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data file2;&lt;BR /&gt;
input ID name$ add2$ Sales$ Flag$;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 nikki mumbai 1000 y&lt;BR /&gt;
2 pavan kochi 2000 n&lt;BR /&gt;
3 prani chennai 1000 y&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select one.ID, one.name, two.sales, two.flag,&lt;BR /&gt;
case when two.flag = 'y' then add2&lt;BR /&gt;
     when two.flag = 'n' then add1&lt;BR /&gt;
	 else 'No Address'&lt;BR /&gt;
end as address&lt;BR /&gt;
from file1 as one,&lt;BR /&gt;
	 file2 as two &lt;BR /&gt;
where one.ID=two.ID;&lt;BR /&gt;
quit;</description>
    <pubDate>Thu, 21 May 2009 10:04:49 GMT</pubDate>
    <dc:creator>LOK</dc:creator>
    <dc:date>2009-05-21T10:04:49Z</dc:date>
    <item>
      <title>merge data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/merge-data/m-p/29341#M6877</link>
      <description>i have 2 files, I merge it by key id &lt;BR /&gt;
&lt;BR /&gt;
file 1&lt;BR /&gt;
v1  id&lt;BR /&gt;
v2 name&lt;BR /&gt;
v3 address1&lt;BR /&gt;
&lt;BR /&gt;
file 2&lt;BR /&gt;
v1 id&lt;BR /&gt;
v2 sales amt&lt;BR /&gt;
v3 address2&lt;BR /&gt;
v4 flag (Y/N)&lt;BR /&gt;
&lt;BR /&gt;
           I want to merge above 2 files by id and if v4 flag in file 2 ="Y"  I will use address2 if ="N" will use address1 in file 1 , output I want &lt;BR /&gt;
&lt;BR /&gt;
                id name sale amt  address(1 or 2)&lt;BR /&gt;
&lt;BR /&gt;
thanks in advance</description>
      <pubDate>Fri, 08 May 2009 08:13:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/merge-data/m-p/29341#M6877</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-08T08:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: merge data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/merge-data/m-p/29342#M6878</link>
      <description>Give this a try mate,  You wil be able to amend where needed&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data file1;&lt;BR /&gt;
infile datalines delimiter=',' missover;&lt;BR /&gt;
length ID name add1 $20. ;&lt;BR /&gt;
input ID name add1 ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1,Allied,1 Test Ave&lt;BR /&gt;
2,Apex,2 Test Cres&lt;BR /&gt;
3,Bluestone,&lt;BR /&gt;
4,Capquest,&lt;BR /&gt;
5,CARS,5 Test View&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data file2;&lt;BR /&gt;
infile datalines delimiter=',' missover;&lt;BR /&gt;
length ID name add2 sale $20. flag $2.;&lt;BR /&gt;
input ID name add2 Sale Flag;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1,Allied,1 Test Ave,1234,Y&lt;BR /&gt;
2,Apex,2 Test Cres,4785,Y&lt;BR /&gt;
3,Bluestone,3 Test Close,88897,N&lt;BR /&gt;
4,Capquest, ,3597,Y&lt;BR /&gt;
5,CARS, ,17112,Y&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table new_table as&lt;BR /&gt;
select a.ID, a.name, b.ID, b.name, b.sale, b.flag, case when a.add1 ne ' ' then add1&lt;BR /&gt;
when a.add1 = ' ' and b.add2 ne ' ' then b.add2		&lt;BR /&gt;
when a.add1 = ' ' and b.add2 = ' ' then 'NO ADDRESS'			  end as add3&lt;BR /&gt;
&lt;BR /&gt;
from file1 as a,&lt;BR /&gt;
     file2 as b&lt;BR /&gt;
&lt;BR /&gt;
where a.id =b.id&lt;BR /&gt;
and b.flag = "Y"&lt;BR /&gt;
;&lt;BR /&gt;
quit;</description>
      <pubDate>Fri, 08 May 2009 11:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/merge-data/m-p/29342#M6878</guid>
      <dc:creator>Doyleuk</dc:creator>
      <dc:date>2009-05-08T11:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: merge data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/merge-data/m-p/29343#M6879</link>
      <description>data file1;&lt;BR /&gt;
input ID name$ add1$ ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 nikki mumbai&lt;BR /&gt;
2 pavan HYD&lt;BR /&gt;
3 prani chennai&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data file2;&lt;BR /&gt;
input ID name$ add2$ Sales$ Flag$;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 nikki mumbai 1000 y&lt;BR /&gt;
2 pavan kochi 2000 n&lt;BR /&gt;
3 prani chennai 1000 y&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select one.ID, one.name, two.sales, two.flag,&lt;BR /&gt;
case when two.flag = 'y' then add2&lt;BR /&gt;
     when two.flag = 'n' then add1&lt;BR /&gt;
	 else 'No Address'&lt;BR /&gt;
end as address&lt;BR /&gt;
from file1 as one,&lt;BR /&gt;
	 file2 as two &lt;BR /&gt;
where one.ID=two.ID;&lt;BR /&gt;
quit;</description>
      <pubDate>Thu, 21 May 2009 10:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/merge-data/m-p/29343#M6879</guid>
      <dc:creator>LOK</dc:creator>
      <dc:date>2009-05-21T10:04:49Z</dc:date>
    </item>
  </channel>
</rss>

