<?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: data merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338108#M76883</link>
    <description>You can solve this in single step by using SQL join instead. It will work but you need to use the put function to convert to char.</description>
    <pubDate>Sat, 04 Mar 2017 11:04:02 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2017-03-04T11:04:02Z</dc:date>
    <item>
      <title>data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338083#M76872</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two datasets which which have one column common to both the datasets.&lt;/P&gt;
&lt;P&gt;Problem is that one variable which is common to both the dataset. Variable C is numeric in dataset A &amp;nbsp;and character in Dataset B, i tried converting numeric to character using input function and then merge the two files into one master file but SAS datastep is not allowing it to convert it to character and keeps the variable numeric and merge fails because of that.&lt;/P&gt;
&lt;P&gt;The merge can only happen if this variable C is character in both the datasets.&lt;/P&gt;
&lt;P&gt;Anyone who faced similar problem, please share any suggestions that can help me merge dataset A and dataset B on variable C.&lt;/P&gt;
&lt;P&gt;Tried using Proc sql too didn't work.&lt;/P&gt;
&lt;P&gt;Any help is appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;RJ&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2017 02:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338083#M76872</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-04T02:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338085#M76874</link>
      <description>&lt;PRE&gt;/*set age to character*/
data probably_have (drop=_age);
  set sashelp.class (rename=(age=_age));
  age=put(_age,$2.);
run;

/*set age to from character to numeric*/
data want (drop=_age);
  set probably_have (rename=(age=_age));
  age=input(_age,8.);
run;


&lt;/PRE&gt;
&lt;P&gt;You can only change a variable's type (and keep its name) by renaming the old variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2017 02:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338085#M76874</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-04T02:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338108#M76883</link>
      <description>You can solve this in single step by using SQL join instead. It will work but you need to use the put function to convert to char.</description>
      <pubDate>Sat, 04 Mar 2017 11:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338108#M76883</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-03-04T11:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338161#M76925</link>
      <description>I tried it but SAS UE is forcing the variable to remain numeric, and I tried using SQL too when i do data merge it doesn't give me any rows but only columns</description>
      <pubDate>Sat, 04 Mar 2017 21:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338161#M76925</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-04T21:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338163#M76926</link>
      <description>&lt;P&gt;Post the code you tried.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2017 21:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338163#M76926</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-04T21:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338264#M76987</link>
      <description>Now even though I changed the variable to character , I'm not able to merge, codes run fine but I am not getting anything in results section, no rows only columns are displayed in results window. &lt;BR /&gt;&lt;BR /&gt;What can be the reason of no rows but only columns in output?&lt;BR /&gt;codes are below&lt;BR /&gt;DATA jan.masterdata5;&lt;BR /&gt;	MERGE jan.summtrd09 (IN=A drop= _type_ _freq_ yr wk) &lt;BR /&gt;	Jan.summdtc1 (IN=B drop = _type_ _freq_ yr wk);&lt;BR /&gt;	BY DMA_1 week_nm ;&lt;BR /&gt;	IF A AND B THEN OUTPUT jan.masterdata5;&lt;BR /&gt;RUN;</description>
      <pubDate>Sun, 05 Mar 2017 19:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338264#M76987</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T19:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338269#M76990</link>
      <description>&lt;P&gt;Post a copy of your log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 19:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338269#M76990</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-05T19:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338270#M76991</link>
      <description>&lt;P&gt;Another thought, as I had understood you were changing the one variable to also be numeric. That would be a lot easier as, using character variables, both character variables have to be the same length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 19:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338270#M76991</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-05T19:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338273#M76993</link>
      <description>The variables I changed are now of same length.</description>
      <pubDate>Sun, 05 Mar 2017 19:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338273#M76993</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T19:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338274#M76994</link>
      <description>Log isn't showing any error. I don't understand why the codes are running fine, the data step is even merging the columns but there is no data in the columns</description>
      <pubDate>Sun, 05 Mar 2017 19:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338274#M76994</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T19:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338276#M76995</link>
      <description>Now that i have tried another join in data merge I am getting an error.&lt;BR /&gt;codes:&lt;BR /&gt;DATA Jan.masterdata11;&lt;BR /&gt;MERGE Jan.summtrd09 (IN=A ) &lt;BR /&gt;	Jan.summdtc1 (IN=B );&lt;BR /&gt;	BY DMA_1 week_nm ;&lt;BR /&gt;IF 	a or b then OUTPUT= Jan.masterdata11;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;log :&lt;BR /&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 55         &lt;BR /&gt; 56         DATA Jan.masterdata11;&lt;BR /&gt; 57         MERGE Jan.summtrd09 (IN=A )&lt;BR /&gt; 58         Jan.summdtc1 (IN=B );&lt;BR /&gt; 59         BY DMA_1 week_nm ;&lt;BR /&gt; 60         IF a or b then OUTPUT= Jan.masterdata11;&lt;BR /&gt;                                    ________________&lt;BR /&gt;                                    557&lt;BR /&gt; ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.&lt;BR /&gt; ERROR 557-185: Variable Jan is not an object.&lt;BR /&gt; &lt;BR /&gt; NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt;       real time           0.02 seconds&lt;BR /&gt;       cpu time            0.02 seconds&lt;BR /&gt;</description>
      <pubDate>Sun, 05 Mar 2017 19:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338276#M76995</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T19:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338279#M76996</link>
      <description>&lt;P&gt;&lt;SPAN&gt;change the line:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;IF a or b then OUTPUT= Jan.masterdata11;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;to:&amp;nbsp;IF a or b;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You could just get rid of the equal sign, but including output jan.masterdata11 would be redundant since you're only outputting one dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Art, CEO, AnalystFinder.com&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 20:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338279#M76996</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-05T20:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338280#M76997</link>
      <description>let me try .</description>
      <pubDate>Sun, 05 Mar 2017 20:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338280#M76997</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T20:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338281#M76998</link>
      <description>if I run the code below :&lt;BR /&gt; DATA Jan.masterdata11;&lt;BR /&gt;MERGE Jan.summtrd09 (IN=A ) &lt;BR /&gt;	Jan.summdtc1 (IN=B );&lt;BR /&gt;	BY DMA_1 week_nm ;&lt;BR /&gt;IF 	A or B;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;then I can see all the columns in my dataset but then I have values missing in most of the columns. &lt;BR /&gt;</description>
      <pubDate>Sun, 05 Mar 2017 20:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338281#M76998</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T20:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338282#M76999</link>
      <description>I checked both Jan.summtrd09 and Jan.summdtc1 before merging there are no missing data there. please advise why the merge is not successful</description>
      <pubDate>Sun, 05 Mar 2017 20:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338282#M76999</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T20:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338283#M77000</link>
      <description>&lt;P&gt;At some point you changed your selection criteria from&lt;/P&gt;
&lt;P&gt;A and B to A or B&lt;/P&gt;
&lt;P&gt;Which do you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as why you are getting a lot of missing values, other than the above reason, you would have to post example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 20:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338283#M77000</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-05T20:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338285#M77001</link>
      <description>I want a and b but i thought maybe changing selection criteria might help in merge.Thanks!</description>
      <pubDate>Sun, 05 Mar 2017 20:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338285#M77001</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T20:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338287#M77002</link>
      <description>Before merging I can see all the data in two files that I am trying to merge. But after merge I don't understand why I am not getting data in output  for some of the columns.</description>
      <pubDate>Sun, 05 Mar 2017 20:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338287#M77002</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-05T20:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338299#M77008</link>
      <description>&lt;P&gt;Can't help you without seeing examples of your two datasets and, based on the examples, what you expect to end up with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 20:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338299#M77008</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-05T20:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: data merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338515#M77098</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems like there was a problem in raw file, even though the common key of two datasets was converted to character, the length of that variable in raw file was different and due to that merge failed.&lt;/P&gt;
&lt;P&gt;even though the SAS codes were correct it was actually length of character variable that didn't help merge two datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 18:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-merge/m-p/338515#M77098</guid>
      <dc:creator>rj</dc:creator>
      <dc:date>2017-03-06T18:02:23Z</dc:date>
    </item>
  </channel>
</rss>

