<?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: How to sum rows of the same date for another variable with two levels (two drugs) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822026#M324567</link>
    <description>&lt;P&gt;Some of us (many of us?) will not work with data from spreadsheets, as they can be a security risk and are often unhelpful in providing data in meaningful form for use in SAS code. Please provide (a portion of) the data as &lt;FONT color="#FF0000"&gt;working&lt;/FONT&gt; SAS data step code which you can type in yourself (and please test your code to ensure that it works) or which you can create following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2022 11:17:37 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-07-07T11:17:37Z</dc:date>
    <item>
      <title>How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822014#M324557</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my first post in the SAS forum, hopefully I provide enough information but happy to adapt my question as needed. I am also relatively new to SAS, so my question may be simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset for which I want to sum all rows of the same date into 1 row but separated by another variable which is drug (there are two drugs). I then want to sum all the total number of prescriptions dispensed by each of these two drugs for each day (this is a third column in my dataset).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I approach this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 10:23:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822014#M324557</guid>
      <dc:creator>mmaximos</dc:creator>
      <dc:date>2022-07-07T10:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822015#M324558</link>
      <description>An example dataset would be nice, it's difficult to situate yourself without seeing it</description>
      <pubDate>Thu, 07 Jul 2022 10:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822015#M324558</guid>
      <dc:creator>AlexBennasar</dc:creator>
      <dc:date>2022-07-07T10:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822016#M324559</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/429136"&gt;@mmaximos&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my first post in the SAS forum, hopefully I provide enough information but happy to adapt my question as needed. I am also relatively new to SAS, so my question may be simple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset for which I want to sum all rows of the same date into 1 row but separated by another variable which is drug (there are two drugs). I then want to sum all the total number of prescriptions dispensed by each of these two drugs for each day (this is a third column in my dataset).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I approach this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/406736"&gt;@AlexBennasar&lt;/a&gt; that providing a sample data set, and providing the desired output from that sample data set, would be greatly helpful. Nevertheless, this seems like something PROC SUMMARY will do easily.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 10:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822016#M324559</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-07T10:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822025#M324566</link>
      <description>Good point, I'm uncertain if I can share an actual sample of my dataset, therefore I've created this sample dataset in google sheets that mimics my dataset: &lt;A href="https://docs.google.com/spreadsheets/d/15sXZBoHmgRVmBreG9JaPZWVTJ7npGpC5bQm3tGF04fc/edit?usp=sharing" target="_blank"&gt;https://docs.google.com/spreadsheets/d/15sXZBoHmgRVmBreG9JaPZWVTJ7npGpC5bQm3tGF04fc/edit?usp=sharing&lt;/A&gt; . The molecule column contains two drugs, the new prescriptions column contains the number of new prescriptions dispensed, the time period represents the year and month for that drug and new prescriptions dispensed. What I want to be able to do is total all the number of incidents of drug_1 and drug_2 for each day in the time period column and also sum all the total number of new prescriptions for each day by drug. The time period column contains multiple years, so if I try to sum by month then I lose the ability to separate by year.&lt;BR /&gt;&lt;BR /&gt;Thank you for your help, it's very much appreciated.&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Jul 2022 10:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822025#M324566</guid>
      <dc:creator>mmaximos</dc:creator>
      <dc:date>2022-07-07T10:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822026#M324567</link>
      <description>&lt;P&gt;Some of us (many of us?) will not work with data from spreadsheets, as they can be a security risk and are often unhelpful in providing data in meaningful form for use in SAS code. Please provide (a portion of) the data as &lt;FONT color="#FF0000"&gt;working&lt;/FONT&gt; SAS data step code which you can type in yourself (and please test your code to ensure that it works) or which you can create following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 11:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822026#M324567</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-07T11:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822031#M324570</link>
      <description>&lt;P&gt;Number of incidents by day (in the _freq_ var of the o1 dataset):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc summary data=yourDS;
class molecule time_period;
types molecule*time_period;
output out=o1;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;New prescriptions by day and drug:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc summary data=yourDS;
var prescriptions;
class molecule time_period;
types molecule*time_period;
output out=o2 sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In fact, the second summary is enough, as you have there the _freq_ var too...&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 11:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822031#M324570</guid>
      <dc:creator>AlexBennasar</dc:creator>
      <dc:date>2022-07-07T11:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822063#M324582</link>
      <description>&lt;P&gt;Your link is not a SAS dataset, it's an Excel spreadsheet. Your column names are not valid SAS names.&lt;/P&gt;
&lt;P&gt;Please post usable data in this form:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Molecule $ Total_New_Prescriptions Time_Period $6.;
datalines;
Drug_1 4 201611
Drug_2 1 201611
Drug_2 9 201611
Drug_1 2 201612
Drug_1 4 201612
Drug_1 3 201612
Drug_2 9 201613
Drug_1 2 201613
Drug_2 6 201613
Drug_2 1 201613
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What does your time period represent? It can't be months, as there ain't a month 13. Are these Julian dates?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 14:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822063#M324582</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-07T14:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822430#M324768</link>
      <description>&lt;P&gt;Thanks for the questions. You are correct, this is not a SAS dataset, which was explained in my initial reply as I cannot link my dataset and I am still learning how to navigate SAS. Thank you for the example of how to post a dataset sample. You are also correct, there is no month 13, that was a flaw in my entry. I think a fellow SAS user may have posted a potential solution, which I will try. If I am still stuck, I will make sure to post a dataset that can be navigated in SAS format if I need to ask further questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jul 2022 13:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822430#M324768</guid>
      <dc:creator>mmaximos</dc:creator>
      <dc:date>2022-07-09T13:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822431#M324769</link>
      <description>&lt;P&gt;This worked great, thank you kindly!&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jul 2022 14:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822431#M324769</guid>
      <dc:creator>mmaximos</dc:creator>
      <dc:date>2022-07-09T14:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum rows of the same date for another variable with two levels (two drugs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822432#M324770</link>
      <description>&lt;P&gt;Thank you, I think my question has been answered, but this is helpful information to know for the future. Appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jul 2022 14:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-rows-of-the-same-date-for-another-variable-with-two/m-p/822432#M324770</guid>
      <dc:creator>mmaximos</dc:creator>
      <dc:date>2022-07-09T14:41:12Z</dc:date>
    </item>
  </channel>
</rss>

