<?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: Move an index based on another one in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Move-an-index-based-on-another-one/m-p/936526#M42085</link>
    <description>&lt;P&gt;If the data are sorted by ID, then there is a single-step solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge db (where=(index=1) in=found_an_index)   db;
  by id;
  index= (event=1 and found_an_index=1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 21 Jul 2024 13:55:39 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2024-07-21T13:55:39Z</dc:date>
    <item>
      <title>Move an index based on another one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Move-an-index-based-on-another-one/m-p/936523#M42083</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$20. Event Index;
cards;
0001 1  0
0001 0  1
0002 1  1
0002 0  0
0003 1  0
0003 0  1
0003 0  1
0003 0  0
0003 0  1
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Each patient has Event = 1 corresponding to the first occurrence (there are dates). The dataset is sorted by Event. So, first.ID = 1. Then there is another column, i.e., Index, corresponding to hospitalizations at different dates (not shown). It doesn't matter if a patient has more than one hospitalization I would like to put index "1" if the patient hast at least one hospitalization. The index should be placed where Event = 1 because subsequent filters will be applied. Can anyone help me please? The desired output should be:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data DB1;
  input ID :$20. Event Index;
cards;
0001 1  1
0001 0  0
0002 1  1
0002 0  0
0003 1  1
0003 0  0
0003 0  0
0003 0  0
0003 0  0
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jul 2024 12:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Move-an-index-based-on-another-one/m-p/936523#M42083</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-07-21T12:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Move an index based on another one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Move-an-index-based-on-another-one/m-p/936524#M42084</link>
      <description>&lt;P&gt;PROC SUMMARY can help here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=db nway;
    class id;
    var index;
    output out=db_max(drop=_:) max=max_index;
run;
data want;
	merge db db_max;
	by id;
	if event=1 and max_index=1 then new_index=1;
	else new_index=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Jul 2024 12:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Move-an-index-based-on-another-one/m-p/936524#M42084</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-21T12:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Move an index based on another one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Move-an-index-based-on-another-one/m-p/936526#M42085</link>
      <description>&lt;P&gt;If the data are sorted by ID, then there is a single-step solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge db (where=(index=1) in=found_an_index)   db;
  by id;
  index= (event=1 and found_an_index=1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Jul 2024 13:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Move-an-index-based-on-another-one/m-p/936526#M42085</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-07-21T13:55:39Z</dc:date>
    </item>
  </channel>
</rss>

