<?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: Merging question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96514#M20372</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Namrata.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While merging two datasets in data step,you have to sort both dataset with the&amp;nbsp; same BY variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So You need to sort &lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;work.WB1 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;dataset based on &lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;country newyear &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;variables.but in your code you are sorting WB1 dataset based on &lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;newyear year.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check.That might be causing Error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sanjeev.K&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Feb 2013 07:48:03 GMT</pubDate>
    <dc:creator>kuridisanjeev</dc:creator>
    <dc:date>2013-02-04T07:48:03Z</dc:date>
    <item>
      <title>Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96512#M20370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Could anybody guide me on this merge task?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Dataset 1(WB)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Country&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newyear&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1995&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1996&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x2&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1997&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x3&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1995&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x4&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1996&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Dataset 2(countries)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Country&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newyear&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Firm&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1995&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y1&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1995&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y2&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1995&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y3&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1996&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y1&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1996&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y2&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1995&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z1&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1995&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z2&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1996&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z1&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1996&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I need to merge these two datasets: basically assign each country's value for each year to each of the firms in that country for the corresponding year. It is a one-to-many merge.&lt;/P&gt;&lt;P&gt;I used these codes.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New;"&gt;"&lt;/SPAN&gt;DM 'log;clear;output;clear';&lt;/P&gt;&lt;P&gt;proc import out= work.WB&lt;/P&gt;&lt;P&gt;datafile= "C:\Users\saikia\Desktop\WB.csv"&lt;/P&gt;&lt;P&gt;DBMS = csv replace;&lt;/P&gt;&lt;P&gt;Getnames= yes;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data WB1;&lt;/P&gt;&lt;P&gt;set WB;&lt;/P&gt;&lt;P&gt;newyear=year*1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*Initially, an error popped up that v46 that represented the year was both numeric and alphanumeric and so I created the variable 'newyear' for both datasets'*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data = work.WB1;&lt;/P&gt;&lt;P&gt;by&amp;nbsp; newyear year;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc import out= work.countries&lt;/P&gt;&lt;P&gt;datafile= "C:\Users\n\Desktop\country.csv"&lt;/P&gt;&lt;P&gt;DBMS = csv replace;&lt;/P&gt;&lt;P&gt;Getnames= yes;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data countries1;&lt;/P&gt;&lt;P&gt;set countries;&lt;/P&gt;&lt;P&gt;newyear=v46*1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data = work.countries1;&lt;/P&gt;&lt;P&gt;by&amp;nbsp; country newyear;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data work.combined;&lt;/P&gt;&lt;P&gt;merge work.WB1(in = in1) work.countries1(in = in2); &lt;/P&gt;&lt;P&gt;by country newyear;&lt;/P&gt;&lt;P&gt;if in1&amp;amp; in2;&lt;/P&gt;&lt;P&gt;run;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error that appears now is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: BY variables are not properly sorted on data set WORK.WB1.&lt;/P&gt;&lt;P&gt;Could anybody please help me?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 04:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96512#M20370</guid>
      <dc:creator>namrata</dc:creator>
      <dc:date>2013-02-04T04:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96513#M20371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;while sorting the data in the data set WORK.WBI&lt;/P&gt;&lt;P&gt;you have given to sort it by two variables "newyear" and ''year"&lt;/P&gt;&lt;P&gt;but the variable "year" is not at all there in your data WORK.WBI&lt;/P&gt;&lt;P&gt;you have only COUNTRY ,NEWYEAR,VAR1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 07:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96513#M20371</guid>
      <dc:creator>Vishnukaushal</dc:creator>
      <dc:date>2013-02-04T07:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96514#M20372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Namrata.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While merging two datasets in data step,you have to sort both dataset with the&amp;nbsp; same BY variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So You need to sort &lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;work.WB1 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;dataset based on &lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;country newyear &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;variables.but in your code you are sorting WB1 dataset based on &lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;newyear year.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check.That might be causing Error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sanjeev.K&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 07:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96514#M20372</guid>
      <dc:creator>kuridisanjeev</dc:creator>
      <dc:date>2013-02-04T07:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96515#M20373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Namrata,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to avoid that error note as suggest by few of the community members you need to sort the wb1 data on country and newyear.&amp;nbsp; This will avoid the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However there is another point which i would to inform you is that, in your post you mentioned that when you tried to import the csv file an error popped up that the year was both numeric and character. It some time happens that in a particular column in excel or csv file we find that there are numeric and character values. While importing sas will check the first 8 rows and will consider the data type based on that, for example if we have first 8 records with numeric and next character, sas will take the remaining records are numeric and display them as missing as character values are there. to avoid this we have a statement in proc import, which is MIXED=YES; if you use this you can avoid that message and there will be no need for you create another variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try it and let me know your feedback&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 08:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96515#M20373</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-02-04T08:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96516#M20374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone.Yes,I had overlooked that sorting variable.&lt;/P&gt;&lt;P&gt;I have corrected the same;still the output table 'combined' has zero observations.Merging does not take place.&lt;/P&gt;&lt;P&gt;The 'MIXED' suggestion is a useful one &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; Thanks!&lt;/P&gt;&lt;P&gt;My friend asked me to use Proc SQL since it is a one-to-many merge...apparently that seems more efficient compared to 'merge' when the 2 datasets do not contain one-to-one correspondence of the ID variables(eg. 1995 of country A in dataset 1 corresponds to several 1995s of country A in dataset 2).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 17:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96516#M20374</guid>
      <dc:creator>namrata</dc:creator>
      <dc:date>2013-02-04T17:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96517#M20375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One to Many merge should work fine with the MERGE statement.&amp;nbsp; It is Many to Many that will work strangely.&lt;/P&gt;&lt;P&gt;Make sure that the variable that you want to copy from the "ONE" dataset is not already present on the "MANY" dataset. (in your example that would be VAR1)&amp;nbsp; If it does appear on both datasets then only the first row of the "MANY" will be updated with the value for the "ONE".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not a big fan of using PROC IMPORT for CSV files. Just write a data step to read the file. That way you can control the way that COUNTRY and YEAR is defined in both datasets to avoid issues of type mismatches or length mismatches.&amp;nbsp; You might also want to UPCASE() the COUNTRY variable to make sure that the value will match between the two sources.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data wb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; infile &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;"C:\Users\saikia\Desktop\WB.csv" dsd dlm=',' truncover lrecl=10000 firstobs=2;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length country $20 year 8 var1 $8 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input country year var1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; country=upcase(country);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sort ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by country year;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data countries ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; infile &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;"C:\Users\n\Desktop\country.csv" dsd dlm=',' truncover lrecl=10000 firstobs=2;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length country $20 year 8 firm $20 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input country year firm;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; country=upcase(country);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sort ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by country year;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; merge wb (in=in1) countries(in=in2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by country year;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if not in1 then put 'NOT in WB ' country= year= firm= ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; else if not in2 then put 'NOT in COUNTRIES ' country= year= var1=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; else output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 23:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96517#M20375</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-04T23:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96518#M20376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom&lt;/P&gt;&lt;P&gt;Your code works &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;. I used it for a small trial dataset to understand.&lt;/P&gt;&lt;P&gt;However, could you please explain what it means: &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: Courier New;"&gt;'NOT in 1' &lt;/SPAN&gt;country= year= var1= var2= ; '?&lt;/P&gt;&lt;P&gt;Should the merged dataset contain 'Not in 1' for country &amp;amp; year observations in file 2 but not corresponding to that in file 1? I find that the merged dataset is one bearing perfect correspondence with both datasets.Any country/year id not contained in both are eliminated.&lt;/P&gt;&lt;P&gt;Also, I find that even if I do not add 'country= year=..',it gives the same output. I was curious since one of my datasets contains a lot of variables.&lt;/P&gt;&lt;P&gt;Thanks a lot,Tom.&lt;/P&gt;&lt;P&gt;I would really appreciate if you could explain the above mentioned&amp;nbsp; parts of the code.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;namrata&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 01:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96518#M20376</guid>
      <dc:creator>namrata</dc:creator>
      <dc:date>2013-02-05T01:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96519#M20377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added those PUT statements because you said that you were getting zero observations when you limited the output to country/year combinations that appeared in both datasets.&amp;nbsp;&amp;nbsp; By looking at the values that were appearing in only one of the two datasets you could possibly debug why the merge was not finding any matching records.&amp;nbsp; If you have fixed whatever the issue was and are not worried about the mismatches then you can eliminate one or both of the put statements.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 03:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96519#M20377</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-05T03:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96520#M20378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom.&lt;/P&gt;&lt;P&gt;Now,I need to use the statements in lieu of Proc Import...&lt;/P&gt;&lt;P&gt;I had a question:if I have a long list of variables in my dataset, is there any option with the INPUT command like using an aseterisk that would account for all variables rather than writing them all out?&lt;/P&gt;&lt;P&gt;Namrata&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Feb 2013 05:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96520#M20378</guid>
      <dc:creator>namrata</dc:creator>
      <dc:date>2013-02-06T05:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Merging question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96521#M20379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can deal with it in a couple of ways.&lt;/P&gt;&lt;P&gt;1) Use PROC IMPORT interactively and recall the data step that it generated and clean it up.&lt;/P&gt;&lt;P&gt;2) Pull in the header line of the CSV file so that you have the variable names.&amp;nbsp; What I normally do this is convert it to a LENGTH statement where I assign the type and length of each variable.&amp;nbsp; I then add and INFORMAT statement for any date or time variables that require special informats to be read properly.&amp;nbsp; Then my input statement can using the xx -- yy syntax to input all of the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile 'my.csv' dsd dlm=',' firstobs=2 truncover lrecl=1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length country $20 year 8 var1 $40 age 8 sex $6 .... lastvar 8 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input country -- lastvar ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) If all of the variables are basically the same then use numeric suffixes on the names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile 'my.csv' dsd dlm=',' firstobs=2 truncover lrecl=1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length country $20 year 8 var1-var30 $20 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input country year var1-var30&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Feb 2013 05:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-question/m-p/96521#M20379</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-06T05:43:45Z</dc:date>
    </item>
  </channel>
</rss>

