<?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 by two variables produce zero ouput observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675268#M203425</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253384"&gt;@mmhxc5&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Inspection_Year&lt;/FONT&gt; -- a &lt;FONT face="courier new,courier"&gt;char 15&lt;/FONT&gt; variable (why not &lt;FONT face="courier new,courier"&gt;char 4&lt;/FONT&gt; or, even better, numeric?) -- is &lt;EM&gt;left&lt;/EM&gt;-aligned in ALL_DATA, but &lt;EM&gt;right&lt;/EM&gt;-aligned in SNOW_DATA. So, the values from SNOW_DATA, e.g., &lt;FONT face="courier new,courier"&gt;'&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2019'&lt;/FONT&gt; don't match those from ALL_DATA, e.g.,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'&lt;/FONT&gt;&amp;nbsp;because of the leading blanks. (&lt;EM&gt;Trailing&lt;/EM&gt; blanks are no problem.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a new dataset (or overwrite SNOW_DATA) with a left-aligned variable &lt;FONT face="courier new,courier"&gt;Inspection_Year&lt;/FONT&gt;&amp;nbsp;and use this dataset in the MERGE step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data snow_data1;
set snow_data;
Inspection_Year=left(Inspection_Year);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I would recommend that you fix the issue (and possibly similar issues with other variables) at the stage where your datasets were initially created (from raw data or other sources), i.e., define variables with reasonable and consistent types, lengths and alignments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Aug 2020 18:16:37 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2020-08-07T18:16:37Z</dc:date>
    <item>
      <title>merge by two variables produce zero ouput observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675143#M203372</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to merge two datasets by STRUCTURE_NUMBER_008 and Inspection_Year if available in both datasets and keep all the variables in the output. when I run the code, it gives zero observation from the merge statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SNOW_FIRNSA05;
merge all_data(in=one) snow_data(in=two) ;
by STRUCTURE_NUMBER_008 Inspection_Year;
if one;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The format for the BY Variables is the same, but I do not know why the code does not work.&lt;/P&gt;&lt;P&gt;I appreciate the time and help I anyone could help me fix this error.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 21:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675143#M203372</guid>
      <dc:creator>mmhxc5</dc:creator>
      <dc:date>2020-08-06T21:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: merge by two variables produce zero ouput observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675148#M203374</link>
      <description>&lt;P&gt;Please provide the log, so that we don't have to reproduce it.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 21:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675148#M203374</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-06T21:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: merge by two variables produce zero ouput observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675149#M203375</link>
      <description>&lt;P&gt;Formats don't matter much, it is the actual value used in the merge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the code you show one strongly suspects there is another issue. Rerun the code and copy from the log the code and any messages, paste on the forum into a code box opened with the &amp;lt;/&amp;gt; icon to preserve formatting of the text.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 21:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675149#M203375</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-06T21:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: merge by two variables produce zero ouput observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675268#M203425</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253384"&gt;@mmhxc5&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Inspection_Year&lt;/FONT&gt; -- a &lt;FONT face="courier new,courier"&gt;char 15&lt;/FONT&gt; variable (why not &lt;FONT face="courier new,courier"&gt;char 4&lt;/FONT&gt; or, even better, numeric?) -- is &lt;EM&gt;left&lt;/EM&gt;-aligned in ALL_DATA, but &lt;EM&gt;right&lt;/EM&gt;-aligned in SNOW_DATA. So, the values from SNOW_DATA, e.g., &lt;FONT face="courier new,courier"&gt;'&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2019'&lt;/FONT&gt; don't match those from ALL_DATA, e.g.,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'&lt;/FONT&gt;&amp;nbsp;because of the leading blanks. (&lt;EM&gt;Trailing&lt;/EM&gt; blanks are no problem.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a new dataset (or overwrite SNOW_DATA) with a left-aligned variable &lt;FONT face="courier new,courier"&gt;Inspection_Year&lt;/FONT&gt;&amp;nbsp;and use this dataset in the MERGE step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data snow_data1;
set snow_data;
Inspection_Year=left(Inspection_Year);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I would recommend that you fix the issue (and possibly similar issues with other variables) at the stage where your datasets were initially created (from raw data or other sources), i.e., define variables with reasonable and consistent types, lengths and alignments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 18:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-by-two-variables-produce-zero-ouput-observation/m-p/675268#M203425</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-08-07T18:16:37Z</dc:date>
    </item>
  </channel>
</rss>

