<?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 DATA step issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140054#M28240</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create a field 'respondent_id' that contains either the s_id, m_id or c_id depending on what activity the user preformed. The data step below works but the issue I'm having is that some users did multiple acts and it is only storing one ID per user.&amp;nbsp; I want the code to just create a new line if the user has more than one activity instead of overwriting the other.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data act.3;&lt;/P&gt;&lt;P&gt;set act.2;&lt;/P&gt;&lt;P&gt;by user_id;&lt;/P&gt;&lt;P&gt;retain user_id s_id m_id c_id Respondent_id;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if user_id and act_id in (28 29) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; respondent_id=c_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if user_id and act_id in (27) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; respondent_id=m_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if user_id and act_id in (25) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; respondent_id=s_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Jan 2015 16:27:02 GMT</pubDate>
    <dc:creator>kbwork</dc:creator>
    <dc:date>2015-01-27T16:27:02Z</dc:date>
    <item>
      <title>DATA step issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140054#M28240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create a field 'respondent_id' that contains either the s_id, m_id or c_id depending on what activity the user preformed. The data step below works but the issue I'm having is that some users did multiple acts and it is only storing one ID per user.&amp;nbsp; I want the code to just create a new line if the user has more than one activity instead of overwriting the other.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data act.3;&lt;/P&gt;&lt;P&gt;set act.2;&lt;/P&gt;&lt;P&gt;by user_id;&lt;/P&gt;&lt;P&gt;retain user_id s_id m_id c_id Respondent_id;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if user_id and act_id in (28 29) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; respondent_id=c_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if user_id and act_id in (27) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; respondent_id=m_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if user_id and act_id in (25) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; respondent_id=s_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 16:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140054#M28240</guid>
      <dc:creator>kbwork</dc:creator>
      <dc:date>2015-01-27T16:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: DATA step issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140055#M28241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if user_id and ...&lt;/P&gt;&lt;P&gt;treats user_id as a boolean variable which is considered true if not 0.&lt;/P&gt;&lt;P&gt;How is act_id stored? The way you handle it, there cannot be more than one activity per record, so all activities will be output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The log of the data step might be helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 16:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140055#M28241</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-01-27T16:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: DATA step issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140056#M28242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;act.3&lt;/STRONG&gt; is not a valid dataset name. This datastep cannot run, contrary to what you are saying. With valid dataset names you might try :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data three;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set two;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if user_id &amp;gt; 0 then do;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select (act_id);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (28, 29) respondent_id=c_id;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (27) respondent_id=m_id;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (25) respondent_id=s_id;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 17:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140056#M28242</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-01-27T17:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: DATA step issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140057#M28243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use an OUTPUT statement to control the output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know what you're expecting the user_id statement in the IF statement to accomplish. It will evaluate to true if the user_id is greater than 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;data act.three;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;set act.two;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;by user_id;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; if user_id and act_id in (28 29) then do;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; respondent_id=c_id;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;output;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; if user_id and act_id in (27) then do;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; respondent_id=m_id;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;output;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; if user_id and act_id in (25) then do;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; respondent_id=s_id;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;output;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 18:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue/m-p/140057#M28243</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-27T18:27:06Z</dc:date>
    </item>
  </channel>
</rss>

