<?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 Translating stata egen command into sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Translating-stata-egen-command-into-sas/m-p/495401#M130738</link>
    <description>&lt;P&gt;Hi! I'm a long-time stata user and new to sas. I'm trying to figure out how to create a new variable based on the sum of the values of another variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In stata, I can do this using the "egen" command. For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;gen CSI1strong = 1 if csi1&amp;gt;5&amp;nbsp;&lt;/P&gt;&lt;P&gt;egen csi1strong=sum(CSI1strong), by(survey)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first line of code creates a new variable, CSI1strong, that is equal to 1 if csi1&amp;gt;5&lt;/P&gt;&lt;P&gt;The second line of code creates a new variable, csi1strong, that is equal to the sum of CSI1strong for all rows of data, by survey.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I reproduce this in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;Eva&lt;/P&gt;</description>
    <pubDate>Thu, 13 Sep 2018 16:59:02 GMT</pubDate>
    <dc:creator>evat</dc:creator>
    <dc:date>2018-09-13T16:59:02Z</dc:date>
    <item>
      <title>Translating stata egen command into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-stata-egen-command-into-sas/m-p/495401#M130738</link>
      <description>&lt;P&gt;Hi! I'm a long-time stata user and new to sas. I'm trying to figure out how to create a new variable based on the sum of the values of another variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In stata, I can do this using the "egen" command. For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;gen CSI1strong = 1 if csi1&amp;gt;5&amp;nbsp;&lt;/P&gt;&lt;P&gt;egen csi1strong=sum(CSI1strong), by(survey)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first line of code creates a new variable, CSI1strong, that is equal to 1 if csi1&amp;gt;5&lt;/P&gt;&lt;P&gt;The second line of code creates a new variable, csi1strong, that is equal to the sum of CSI1strong for all rows of data, by survey.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I reproduce this in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;Eva&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 16:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-stata-egen-command-into-sas/m-p/495401#M130738</guid>
      <dc:creator>evat</dc:creator>
      <dc:date>2018-09-13T16:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Translating stata egen command into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-stata-egen-command-into-sas/m-p/495417#M130742</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/233171"&gt;@evat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi! I'm a long-time stata user and new to sas. I'm trying to figure out how to create a new variable based on the sum of the values of another variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In stata, I can do this using the "egen" command. For example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;gen CSI1strong = 1 if csi1&amp;gt;5&amp;nbsp;&lt;/P&gt;
&lt;P&gt;egen csi1strong=sum(CSI1strong), by(survey)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first line of code creates a new variable, CSI1strong, that is equal to 1 if csi1&amp;gt;5&lt;/P&gt;
&lt;P&gt;The second line of code creates a new variable, csi1strong, that is equal to the sum of CSI1strong for all rows of data, by survey.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I reproduce this in SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;
&lt;P&gt;Eva&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It would help SAS users more to provide an example of the starting data, the desired result and a description of what goes on if the two examples aren't very straight forward.&lt;/P&gt;
&lt;P&gt;SUMing a variable in groups can be done in Proc Means or summary with the groups defined by CLASS variable(s), or in Proc Sql with a Group by.&lt;/P&gt;
&lt;P&gt;Then combine the results, how will depend on the data sets.&lt;/P&gt;
&lt;P&gt;I don't speak STATA, so that syntax means nothing.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 17:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-stata-egen-command-into-sas/m-p/495417#M130742</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-13T17:27:32Z</dc:date>
    </item>
  </channel>
</rss>

