<?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: ERROR: Subquery evaluated to more than one row. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189769#M35808</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;when there are multiple obs selected in A2 with &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; month='jan' and sno&lt;/SPAN&gt; equal the current obs's sno &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; (select count(*) from a2 where month='jan' and sno=a.sno)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gt 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then set it as role of A2 when &lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;sno&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; equal the current obs's sno&amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 19 Oct 2014 10:36:22 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2014-10-19T10:36:22Z</dc:date>
    <item>
      <title>ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189762#M35801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data a1;&lt;/P&gt;&lt;P&gt;input sno name $ sal;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 jagan 300&lt;/P&gt;&lt;P&gt;2 Karti&amp;nbsp;&amp;nbsp; 400&lt;/P&gt;&lt;P&gt;3 Vankat 500&lt;/P&gt;&lt;P&gt;2 jagan 300&lt;/P&gt;&lt;P&gt;2 Karti&amp;nbsp;&amp;nbsp; 400&lt;/P&gt;&lt;P&gt;3 Vankat 500&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a2;&lt;/P&gt;&lt;P&gt;input month$ sno role$;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;jan 1 Clerk&lt;/P&gt;&lt;P&gt;Feb 2 Cook&lt;/P&gt;&lt;P&gt;Nar 3 Account&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking for output:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sno&amp;nbsp; name&amp;nbsp;&amp;nbsp; sal&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jan&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feb&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jagan&amp;nbsp; 300&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clerk&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cook&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Karti&amp;nbsp;&amp;nbsp;&amp;nbsp; 400&amp;nbsp;&amp;nbsp;&amp;nbsp; cook&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cook&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; venkat&amp;nbsp; 500&amp;nbsp;&amp;nbsp;&amp;nbsp; accounts&amp;nbsp; Accounts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: For every new month I must&amp;nbsp; get a new column(one month lag).&lt;/P&gt;&lt;P&gt;Ex If I'm in month of april I must fill there roles for month march&amp;nbsp; and column name as march.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the query which i wrote but i'm getting error&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table a3&lt;/P&gt;&lt;P&gt;as&lt;/P&gt;&lt;P&gt;select a.*,&lt;/P&gt;&lt;P&gt;case when sno in (select sno from a2 where month='jan')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then&lt;/P&gt;&lt;P&gt;( select b.role from a1 as a left join a2 as b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.sno=b.sno)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else '#n/a' end as Jan&lt;/P&gt;&lt;P&gt;from a1 as a;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help out to solve this issue&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 15:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189762#M35801</guid>
      <dc:creator>pallis</dc:creator>
      <dc:date>2014-10-17T15:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189763#M35802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are you trying to do based on this query?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 15:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189763#M35802</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-10-17T15:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189764#M35803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks to me like you are just doing a left join of the two tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table a3 as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a1.*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , coalesce(a2.role,'#n/a') as Jan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from a1 left join a2 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a1.sno=a2.sno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and a2.month = 'jan'&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 19:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189764#M35803</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-10-17T19:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189765#M35804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for late reply.&lt;/P&gt;&lt;P&gt;Here my intention was to create month on month designation of the employee&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Oct 2014 05:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189765#M35804</guid>
      <dc:creator>pallis</dc:creator>
      <dc:date>2014-10-18T05:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189766#M35805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you didn't post what output you need . Try this one :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
data a1;
input sno name $ sal;
datalines;
1 jagan 300
2 Karti&amp;nbsp;&amp;nbsp; 400
3 Vankat 500
2 jagan 300
2 Karti&amp;nbsp;&amp;nbsp; 400
3 Vankat 500
;
run;
 
 
data a2;
input month$ sno role$;
datalines;
jan 1 Clerk
Feb 2 Cook
Nar 3 Account
;
run;
 
proc sql;
create table a3
as
select a.*,
case when (select count(*) from a2 where month='jan' and sno=a.sno)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gt 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then
( select role from a2 where&amp;nbsp; sno=a.sno)
&amp;nbsp;&amp;nbsp; else '#n/a' end as Jan
from a1 as a;
quit;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Oct 2014 14:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189766#M35805</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-18T14:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189767#M35806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use PROC TRANSPOSE to convert A2.&lt;/P&gt;&lt;P&gt;proc transpose data=a2 out=month_role ;&lt;/P&gt;&lt;P&gt; by sno;&lt;/P&gt;&lt;P&gt; id month;&lt;/P&gt;&lt;P&gt; var role ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Then just merge by SNO.&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge a1 month_role ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by sno;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Oct 2014 15:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189767#M35806</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-10-18T15:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189768#M35807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you explain me the process/execution steps how this case statements works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case when (select count(*) from a2 where month='jan' and sno=a.sno)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gt 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then&lt;/P&gt;&lt;P&gt;( select role from a2 where&amp;nbsp; sno=a.sno)&lt;/P&gt;&lt;P&gt;from a1 as a.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the Then Clause if there are multiple records then clause Will return more than one row isnt. Can you correct me if im wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Oct 2014 10:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189768#M35807</guid>
      <dc:creator>pallis</dc:creator>
      <dc:date>2014-10-19T10:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189769#M35808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;when there are multiple obs selected in A2 with &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; month='jan' and sno&lt;/SPAN&gt; equal the current obs's sno &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; (select count(*) from a2 where month='jan' and sno=a.sno)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gt 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then set it as role of A2 when &lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;sno&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; equal the current obs's sno&amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Oct 2014 10:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189769#M35808</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-19T10:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189770#M35809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the late reply.&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; My data is 173424. When I apply the above logic the query is taking more than 30 min. I have 2000 records in my master. I created index. But still no use of it. Is there any other way to increase performance.&lt;/P&gt;&lt;P&gt;Can you suggest me. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 16:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189770#M35809</guid>
      <dc:creator>pallis</dc:creator>
      <dc:date>2014-10-22T16:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189771#M35810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh . I would suggest to use data step , it was usually faster than sql in this scenario .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189771#M35810</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-23T13:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Subquery evaluated to more than one row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189772#M35811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I Transpose the data and mapped with by transactional data. It worked issue is solved. Thanks for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 15:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Subquery-evaluated-to-more-than-one-row/m-p/189772#M35811</guid>
      <dc:creator>pallis</dc:creator>
      <dc:date>2015-03-18T15:03:35Z</dc:date>
    </item>
  </channel>
</rss>

