<?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 By group in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/By-group/m-p/45925#M1337</link>
    <description>data xx;&lt;BR /&gt;
  input usubjid visit result $ 5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 1 a&lt;BR /&gt;
1 2 a&lt;BR /&gt;
1 3 n&lt;BR /&gt;
2 1 n&lt;BR /&gt;
2 2 n&lt;BR /&gt;
2 3 n&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
if usubjid having any one of the visit, result=a then that usubjid  should have new variable x='a' other  wise usubjid should have x='n'.&lt;BR /&gt;
&lt;BR /&gt;
example:&lt;BR /&gt;
&lt;BR /&gt;
above data set will be having below output:&lt;BR /&gt;
&lt;BR /&gt;
usubjid   x&lt;BR /&gt;
1           a&lt;BR /&gt;
2           n&lt;BR /&gt;
&lt;BR /&gt;
To get this output please give me some sas code.</description>
    <pubDate>Mon, 15 Sep 2008 09:59:18 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-09-15T09:59:18Z</dc:date>
    <item>
      <title>By group</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/By-group/m-p/45925#M1337</link>
      <description>data xx;&lt;BR /&gt;
  input usubjid visit result $ 5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 1 a&lt;BR /&gt;
1 2 a&lt;BR /&gt;
1 3 n&lt;BR /&gt;
2 1 n&lt;BR /&gt;
2 2 n&lt;BR /&gt;
2 3 n&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
if usubjid having any one of the visit, result=a then that usubjid  should have new variable x='a' other  wise usubjid should have x='n'.&lt;BR /&gt;
&lt;BR /&gt;
example:&lt;BR /&gt;
&lt;BR /&gt;
above data set will be having below output:&lt;BR /&gt;
&lt;BR /&gt;
usubjid   x&lt;BR /&gt;
1           a&lt;BR /&gt;
2           n&lt;BR /&gt;
&lt;BR /&gt;
To get this output please give me some sas code.</description>
      <pubDate>Mon, 15 Sep 2008 09:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/By-group/m-p/45925#M1337</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-15T09:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: By group</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/By-group/m-p/45926#M1338</link>
      <description>data xx;&lt;BR /&gt;
input usubjid visit result $ 5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 1 a&lt;BR /&gt;
1 2 a&lt;BR /&gt;
1 3 n&lt;BR /&gt;
2 1 n&lt;BR /&gt;
2 2 n&lt;BR /&gt;
2 3 n&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=xx;&lt;BR /&gt;
by usubjid result;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data xxxx;&lt;BR /&gt;
set xx;&lt;BR /&gt;
by usubjid result;&lt;BR /&gt;
if first.usubjid and first.result and result='a' then x='a';&lt;BR /&gt;
else x='n';&lt;BR /&gt;
keep usubjid x;&lt;BR /&gt;
if first.usubjid and first.result;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Try this it will work.</description>
      <pubDate>Mon, 15 Sep 2008 13:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/By-group/m-p/45926#M1338</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-15T13:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: By group</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/By-group/m-p/45927#M1339</link>
      <description>A more general-purpose code logic would be to use IF FIRST.usubjid THEN DO; END; logic to test initialize a "temporary" SAS variable to the desired no-match condition, and use a RETAIN to keep track of this variable, and if the desired "match" condition is encountered for the "test" variable, set the "temporary" variable to a given value.  The, use the IF LAST.usubjid THEN DO; END; logic to reset RESULT to the temporary variable and do an OUTPUT.&lt;BR /&gt;
&lt;BR /&gt;
This logic flow does not require a particular sort-sequence or "match" value order condition to work properly.  The key here is using the RETAIN statement to track a temporary variable in the DATA step (remember to either DROP this var or specify a KEEP statement).&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Mon, 15 Sep 2008 13:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/By-group/m-p/45927#M1339</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-09-15T13:55:32Z</dc:date>
    </item>
  </channel>
</rss>

