<?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: Query in proc sql to obtain count where price is higher than average price in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820575#M323897</link>
    <description>&lt;P&gt;hmm sort of. how are you getting average price. it seems like this could be done with a subquery.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2022 19:23:15 GMT</pubDate>
    <dc:creator>tarheel13</dc:creator>
    <dc:date>2022-06-27T19:23:15Z</dc:date>
    <item>
      <title>Query in proc sql to obtain count where price is higher than average price</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820218#M323723</link>
      <description>&lt;P&gt;&amp;nbsp;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following tables:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* Tabela Artigos */
proc sql;
   create table artigos
       (REFERENCIA char(1),
        ID_DPTO num,
		COD_FAMILIA char(3),
        DATA_ALTA num informat=DDMMYY10.
                  format=DDMMYY10.
        );

insert into artigos
    values('A',1,'1F1','21FEB10'd)
    values('B',2,'2F1','07FEB14'd)
    values('C',2,'2F1','15MAY14'd)
	values('D',2,'2F1','01OCT05'd)
	values('E',2,'2F1','31OCT10'd)
	values('F',3,'3F1','20APR01'd)
	values('G',3,'3F2','14FEB15'd)
	values('H',4,'4F1','25MAR09'd);
quit;


/* Tabela Campanhas */
proc sql;
   create table campanhas
       (ID_CAMPANHA char(3),
        TIPO char(20),
		DATA_CAMP num informat=DDMMYY10.
                  format=DDMMYY10.
        );

insert into campanhas
    values('CA1','VENDA','05FEB12'd)
    values('CA2','VENDA','04FEB12'd)
    values('CA3','PÓS-VENDA','02OCT09'd)
	values('CA4','VENDA','06MAY10'd)
	values('CA5','PÓS-VENDA','30NOV10'd)
	values('CA6','PÓS-VENDA','07FEB15'd);
quit;


/* Tabela Departamento Campanha */
proc sql;
   create table depto_campanha
       (ID_DPTO num,
        ID_CAMPANHA char(3) 
        );

insert into depto_campanha
    values(1,'CA1')
    values(1,'CA4')
    values(2,'CA2')
	values(3,'CA2')
	values(3,'CA5')
	values(3,'CA6')
	values(4,'CA1')
	values(4,'CA2')
	values(4,'CA3')
	values(4,'CA6');
quit;



/* Tabela Vendas */
proc sql;
   create table vendas
       (TALAO num informat=z2.
                  format=z2.,
        REFERENCIA char(1),
		PRECO num,
        DATA_VENDA num informat=DDMMYY10.
                  format=DDMMYY10.
        );

insert into vendas
    values(01,'A',15,'11FEB12'd)
	values(02,'A',18,'15FEB12'd)
	values(03,'A',14,'02OCT13'd)
	values(04,'D',37.95,'06AUG12'd)
	values(05,'E',125.95,'30NOV10'd)
	values(06,'E',150,'05FEB11'd)
	values(07,'H',22.99,'11APR10'd)
	values(08,'H',24,'08AUG11'd);
quit;&lt;/PRE&gt;&lt;P&gt;I need to create a query (only one and in sql)&amp;nbsp;&lt;SPAN class=""&gt;&amp;nbsp;in which, for each campaign of the "VENDA" type (column "TIPO"), i obtain the average value of beads (column "TALAO"), the number of purchased references (column "REFERENCIAS") and the number of beads ("TALAO") with sales (column "PRECO") higher than the average value of the receipt.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I already could accomplish part of it but in my query i don't obtai the last part "number of beads with sales higher than the average value of the receipt". Can anyone help me here?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;My solution so far:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;proc sql;
select 
t1.id_campanha
,t1.tipo
,avg(t4.preco) as avg_price_&lt;SPAN class=""&gt;beads &lt;/SPAN&gt;
,count(distinct t3.referencia) as nr_referencies
,count(distinct t4.talao) as nr_&lt;SPAN class=""&gt;beads &lt;/SPAN&gt;
from campanhas t1
left join depto_campanha t2 on t1.id_campanha=t2.id_campanha
left join artigos t3 on t2.id_dpto=t3.id_dpto
inner join vendas t4 on t4.referencia=t3.referencia 
where t1.tipo="VENDA"
group by 1,2
having  t4.preco &amp;gt; avg_price_&lt;SPAN class=""&gt;beads &lt;/SPAN&gt;;
quit;&lt;/PRE&gt;&lt;P&gt;I also tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
select 
t1.id_campanha
,t1.tipo
,avg(t4.preco) as avg_price_&lt;SPAN class=""&gt;beads &lt;/SPAN&gt;
,count(distinct t3.referencia) as nr_referencies
,count(distinct case when  t4.preco &amp;gt; calculated avg_price_&lt;SPAN class=""&gt;beads &lt;/SPAN&gt;then t4.talao end ) as nr_&lt;SPAN class=""&gt;beads &lt;/SPAN&gt;
from campanhas t1
left join depto_campanha t2 on t1.id_campanha=t2.id_campanha
left join artigos t3 on t2.id_dpto=t3.id_dpto
inner join vendas t4 on t4.referencia=t3.referencia 
where t1.tipo="VENDA"
group by 1,2
 ;
quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 11:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820218#M323723</guid>
      <dc:creator>msf2021</dc:creator>
      <dc:date>2022-06-24T11:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Query in proc sql to obtain count where price is higher than average price</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820228#M323729</link>
      <description>&lt;P&gt;I'm sure you can do this in PROC SQL, but I won't give it a try. I would use PROC STDIZE to determine which observations are greater than the average, and then count those using PROC FREQ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc stdize data=have out=intermediate;
    var x1; /* Your variable name goes here */
run;
proc format;
    value gt_avg low-0='Below Average' 0&amp;lt;-high='Above Average';
run;
proc freq data=intermediate;
    tables x1/out=want; /* Your variable name goes here */
    format x1 gt_avg.; /* Your variable name goes here */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 12:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820228#M323729</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-24T12:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Query in proc sql to obtain count where price is higher than average price</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820246#M323735</link>
      <description>&lt;P&gt;Which table is receipts?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 14:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820246#M323735</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-24T14:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Query in proc sql to obtain count where price is higher than average price</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820436#M323826</link>
      <description>&lt;P&gt;table "Vendas"&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jun 2022 13:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820436#M323826</guid>
      <dc:creator>msf2021</dc:creator>
      <dc:date>2022-06-26T13:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Query in proc sql to obtain count where price is higher than average price</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820438#M323827</link>
      <description>&lt;P&gt;ok the requirements are a little unclear to me. I don't have a good enough understanding of your data.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jun 2022 16:25:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820438#M323827</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-26T16:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Query in proc sql to obtain count where price is higher than average price</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820439#M323828</link>
      <description>&lt;P&gt;What about now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE class=""&gt;&lt;SPAN class=""&gt;/* Table Articles */&lt;/SPAN&gt;
proc &lt;SPAN class=""&gt;sql&lt;/SPAN&gt;;
   &lt;SPAN class=""&gt;create&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; articles
       (REFERENCY &lt;SPAN class=""&gt;char&lt;/SPAN&gt;(&lt;SPAN class=""&gt;1&lt;/SPAN&gt;),
        ID_DPTO num,
        COD_FAMILIA &lt;SPAN class=""&gt;char&lt;/SPAN&gt;(&lt;SPAN class=""&gt;3&lt;/SPAN&gt;),
        DATA_ALTA num informat&lt;SPAN class=""&gt;=&lt;/SPAN&gt;DDMMYY10.
                  format&lt;SPAN class=""&gt;=&lt;/SPAN&gt;DDMMYY10.
        );

&lt;SPAN class=""&gt;insert&lt;/SPAN&gt; &lt;SPAN class=""&gt;into&lt;/SPAN&gt; articles
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'A'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;1&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'1F1'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'21FEB10'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'B'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;2&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'2F1'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'07FEB14'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'C'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;2&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'2F1'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'15MAY14'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'D'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;2&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'2F1'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'01OCT05'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'E'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;2&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'2F1'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'31OCT10'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'F'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;3&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'3F1'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'20APR01'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'G'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;3&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'3F2'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'14FEB15'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'H'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;4&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'4F1'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'25MAR09'&lt;/SPAN&gt;d);
quit;


&lt;SPAN class=""&gt;/* Table CAMPAIGNS */&lt;/SPAN&gt;
proc &lt;SPAN class=""&gt;sql&lt;/SPAN&gt;;
   &lt;SPAN class=""&gt;create&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; CAMPAIGNS
       (ID_CAMPAIGN &lt;SPAN class=""&gt;char&lt;/SPAN&gt;(&lt;SPAN class=""&gt;3&lt;/SPAN&gt;),
        TYPE &lt;SPAN class=""&gt;char&lt;/SPAN&gt;(&lt;SPAN class=""&gt;20&lt;/SPAN&gt;),
        DATA_CAMP num informat&lt;SPAN class=""&gt;=&lt;/SPAN&gt;DDMMYY10.
                  format&lt;SPAN class=""&gt;=&lt;/SPAN&gt;DDMMYY10.
        );

&lt;SPAN class=""&gt;insert&lt;/SPAN&gt; &lt;SPAN class=""&gt;into&lt;/SPAN&gt; CAMPAIGNS
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'CA1'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'VENDA'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'05FEB12'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'CA2'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'VENDA'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'04FEB12'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'CA3'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'PÓS-VENDA'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'02OCT09'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'CA4'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'VENDA'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'06MAY10'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'CA5'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'PÓS-VENDA'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'30NOV10'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'CA6'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'PÓS-VENDA'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'07FEB15'&lt;/SPAN&gt;d);
quit;


&lt;SPAN class=""&gt;/* Table DEPARTMENT CAMPAIGN */&lt;/SPAN&gt;
proc &lt;SPAN class=""&gt;sql&lt;/SPAN&gt;;
   &lt;SPAN class=""&gt;create&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; depto_CAMPAIGN
       (ID_DPTO num,
        ID_CAMPAIGN &lt;SPAN class=""&gt;char&lt;/SPAN&gt;(&lt;SPAN class=""&gt;3&lt;/SPAN&gt;) 
        );

&lt;SPAN class=""&gt;insert&lt;/SPAN&gt; &lt;SPAN class=""&gt;into&lt;/SPAN&gt; depto_CAMPAIGN
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;1&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA1'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;1&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA4'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;2&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA2'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;3&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA2'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;3&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA5'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;3&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA6'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;4&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA1'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;4&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA2'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;4&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA3'&lt;/SPAN&gt;)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;4&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'CA6'&lt;/SPAN&gt;);
quit;



&lt;SPAN class=""&gt;/* Table SALES */&lt;/SPAN&gt;
proc &lt;SPAN class=""&gt;sql&lt;/SPAN&gt;;
   &lt;SPAN class=""&gt;create&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; SALES
       (BEAD num informat&lt;SPAN class=""&gt;=&lt;/SPAN&gt;z2.
                  format&lt;SPAN class=""&gt;=&lt;/SPAN&gt;z2.,
        REFERENCY &lt;SPAN class=""&gt;char&lt;/SPAN&gt;(&lt;SPAN class=""&gt;1&lt;/SPAN&gt;),
        PRICE num,
        DATA_VENDA num informat&lt;SPAN class=""&gt;=&lt;/SPAN&gt;DDMMYY10.
                  format&lt;SPAN class=""&gt;=&lt;/SPAN&gt;DDMMYY10.
        );

&lt;SPAN class=""&gt;insert&lt;/SPAN&gt; &lt;SPAN class=""&gt;into&lt;/SPAN&gt; SALES
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;01&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'A'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;15&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'11FEB12'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;02&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'A'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;18&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'15FEB12'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;03&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'A'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;14&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'02OCT13'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;04&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'D'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;37.95&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'06AUG12'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;05&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'E'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;125.95&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'30NOV10'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;06&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'E'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;150&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'05FEB11'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;07&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'H'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;22.99&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'11APR10'&lt;/SPAN&gt;d)
    &lt;SPAN class=""&gt;values&lt;/SPAN&gt;(&lt;SPAN class=""&gt;08&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'H'&lt;/SPAN&gt;,&lt;SPAN class=""&gt;24&lt;/SPAN&gt;,&lt;SPAN class=""&gt;'08AUG11'&lt;/SPAN&gt;d);
quit;&lt;/CODE&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I need to create a query (only one and in sql) in which, for each campaign of the "VENDA" type (column "TYPE"), i obtain the average value of beads (column "BEAD"), the number of purchased references (column "REFERENCYS") and the number of beads ("BEAD") with sales (column "PRICE") higher than the average price.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jun 2022 16:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820439#M323828</guid>
      <dc:creator>msf2021</dc:creator>
      <dc:date>2022-06-26T16:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Query in proc sql to obtain count where price is higher than average price</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820575#M323897</link>
      <description>&lt;P&gt;hmm sort of. how are you getting average price. it seems like this could be done with a subquery.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 19:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-proc-sql-to-obtain-count-where-price-is-higher-than/m-p/820575#M323897</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-27T19:23:15Z</dc:date>
    </item>
  </channel>
</rss>

