<?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: summarizing with conditional output in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/summarizing-with-conditional-output/m-p/883211#M39190</link>
    <description>&lt;P&gt;Let's start with this part&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I need to create 3 datasets(d1 d2 d3)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This makes the rest of your problem more difficult to code, and in fact is completely unnecessary (and a bad idea as well). Keep everything in one data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now that we have skipped the unnecessary creation of separate data sets, you can do the summing very easily&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=blib.usorders04(where=(total_retail_price&amp;gt;100)) nway;
    class order_type customer;
    var total_retail_price;
    output out=want sum=total_sales;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output data set that I have named WANT has everything you need.&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jul 2023 17:51:11 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-07-01T17:51:11Z</dc:date>
    <item>
      <title>summarizing with conditional output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/summarizing-with-conditional-output/m-p/883209#M39188</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can anyone please help me with the following :&lt;/P&gt;&lt;P&gt;I have data, where customers spending more than$100 is rewaded. I need to create 3 datasets(d1 d2 d3),the variable order_type indicates whether sale was retail(=1),catalog(=2),internet(=3).the variable total_retail_price is the amount the customer spends on each individual order. I need to create variable totsales to hold total sales to each customer by order_type.A customer can output to more than 1 dataset if he spents $100&amp;nbsp; or more in retail&amp;nbsp; and internet.&lt;/P&gt;&lt;PRE&gt;data s;
set blib.usorders04;
where total_retail_price&amp;gt;100;
run;
proc sort data=s out=s1;
by order_type;
run;
data d1 d2 d3;
set s1;
totsales=sum(total_retail_price);
by order_type;
if order_type=1 then output d1;
if order_type=2 then output d3;
if order_type=3 then output d3;
proc print data=d1;
run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jul 2023 17:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/summarizing-with-conditional-output/m-p/883209#M39188</guid>
      <dc:creator>dona17</dc:creator>
      <dc:date>2023-07-01T17:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: summarizing with conditional output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/summarizing-with-conditional-output/m-p/883211#M39190</link>
      <description>&lt;P&gt;Let's start with this part&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I need to create 3 datasets(d1 d2 d3)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This makes the rest of your problem more difficult to code, and in fact is completely unnecessary (and a bad idea as well). Keep everything in one data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now that we have skipped the unnecessary creation of separate data sets, you can do the summing very easily&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=blib.usorders04(where=(total_retail_price&amp;gt;100)) nway;
    class order_type customer;
    var total_retail_price;
    output out=want sum=total_sales;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output data set that I have named WANT has everything you need.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2023 17:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/summarizing-with-conditional-output/m-p/883211#M39190</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-01T17:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: summarizing with conditional output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/summarizing-with-conditional-output/m-p/883251#M39203</link>
      <description>&lt;P&gt;thanks, it is working.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2023 15:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/summarizing-with-conditional-output/m-p/883251#M39203</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2023-07-02T15:18:32Z</dc:date>
    </item>
  </channel>
</rss>

