<?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: Renaming variable based on a correlation file and Subquerry error in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-variable-based-on-a-correlation-file-and-Subquerry/m-p/756444#M80822</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350498"&gt;@Blandine&lt;/a&gt;&amp;nbsp;Yes, if this is still an active problem let us know. Please also provide some representative sample data via SAS data steps that shows the issue and the desired outcome.&lt;/P&gt;
&lt;P&gt;Not sure that I really understand what you describe as it sounds like you would end-up in duplicate ID's with what you're trying to achieve. Providing representative sample data will make it much easier for us to understand the problem and provide code that's actually fully working.&lt;/P&gt;</description>
    <pubDate>Sun, 25 Jul 2021 01:42:59 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-07-25T01:42:59Z</dc:date>
    <item>
      <title>Renaming variable based on a correlation file and Subquerry error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-variable-based-on-a-correlation-file-and-Subquerry/m-p/753190#M80771</link>
      <description>&lt;P&gt;Hello, I am having a file&amp;nbsp; with data fragmentation.&amp;nbsp;The variable "Structure_name" (in the file WA.WA_datanewname) has 2 ID for the same bridge and I'm trying to make it 1 ID using a correlation file (fh_wa02) that was given to me. The correlation file has old_structure_number_008 and&amp;nbsp;New_structure_number_008, so basically replace I want to replace the old_structure_number_008 with the&amp;nbsp;New_structure_number_008 without lossing any data. But I am having 2 problems:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1-&amp;nbsp; The subquery error below. I solve it by deleting that structure number which is probably not an efficient solution&lt;/P&gt;
&lt;P&gt;ERROR: Subquery evaluated to more than one row.&lt;BR /&gt;NOTE: Correlation values are: Structure_Number='WN-005051656925&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. It's seemed like I am losing some bridge ID. I have 4 bridges that I checked if the code correctly replace the&amp;nbsp; old_structure_number_008 with the&amp;nbsp;New_structure_number_008 but the code simply deleted the&amp;nbsp;old_structure_number_008 . I don't know what to do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table WA.WA_NBI_data_corrected as&lt;BR /&gt;select&lt;BR /&gt;case when exists (select * from fh.fhwa_WA02 where OLD_STRUCTURE_NUMBER_008=Structure_Number)&lt;BR /&gt;then (select NEW_STRUCTURE_NUMBER_008 from fh.fhwa_WA02 where OLD_STRUCTURE_NUMBER_008=Structure_Number)&lt;BR /&gt;else Structure_Number&lt;BR /&gt;end as Structure_Number&lt;BR /&gt;, Year_Built&lt;BR /&gt;, ADT&lt;BR /&gt;, STRUCTURE_KIND_043A&lt;BR /&gt;, STRUCTURE_KIND_043B&lt;BR /&gt;, Bridge_Age&lt;BR /&gt;, DECK_COND_058&lt;BR /&gt;, SUPERSTRUCTURE_COND_059&lt;BR /&gt;, SUBSTRUCTURE_COND_060&lt;BR /&gt;, Deck_Structure_Type&lt;BR /&gt;, Inspection_Year&lt;BR /&gt;from WA.WA_datanewname;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 15:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-variable-based-on-a-correlation-file-and-Subquerry/m-p/753190#M80771</guid>
      <dc:creator>Blandine</dc:creator>
      <dc:date>2021-07-09T15:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variable based on a correlation file and Subquerry error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-variable-based-on-a-correlation-file-and-Subquerry/m-p/756417#M80821</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350498"&gt;@Blandine&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see that for some reason no one has replied.&amp;nbsp; Is this still an active question?&amp;nbsp; If it is still active, I'll help you if I can.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350498"&gt;@Blandine&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;1-&amp;nbsp; The subquery error below. I solve it by deleting that structure number which is probably not an efficient solution&lt;/P&gt;
&lt;P&gt;ERROR: Subquery evaluated to more than one row.&lt;BR /&gt;NOTE: Correlation values are: Structure_Number='WN-005051656925&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;case when exists (select * from fh.fhwa_WA02 where OLD_STRUCTURE_NUMBER_008=Structure_Number)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Have you tried switching the subquery from a simple Select to a Select &lt;STRONG&gt;Distinct&lt;/STRONG&gt;?&amp;nbsp; That should eliminate the "Subquery evaluated to more than one row" problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jul 2021 17:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-variable-based-on-a-correlation-file-and-Subquerry/m-p/756417#M80821</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-07-24T17:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variable based on a correlation file and Subquerry error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-variable-based-on-a-correlation-file-and-Subquerry/m-p/756444#M80822</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350498"&gt;@Blandine&lt;/a&gt;&amp;nbsp;Yes, if this is still an active problem let us know. Please also provide some representative sample data via SAS data steps that shows the issue and the desired outcome.&lt;/P&gt;
&lt;P&gt;Not sure that I really understand what you describe as it sounds like you would end-up in duplicate ID's with what you're trying to achieve. Providing representative sample data will make it much easier for us to understand the problem and provide code that's actually fully working.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Jul 2021 01:42:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-variable-based-on-a-correlation-file-and-Subquerry/m-p/756444#M80822</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-07-25T01:42:59Z</dc:date>
    </item>
  </channel>
</rss>

