<?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 make a group category in a dataset with multiple iterations for a single patient? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788000#M251861</link>
    <description>&lt;P&gt;Why does&amp;nbsp;&lt;SPAN&gt;retrieval_interation contain the color values suddenly? Is that a typo?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jan 2022 20:21:31 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2022-01-01T20:21:31Z</dc:date>
    <item>
      <title>How to make a group category in a dataset with multiple iterations for a single patient?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/787999#M251860</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on a data set in which a person has multiple observations (rows). A person can retrieve balls that vary in color. A person can also transfer and re-store balls in the same bin. I need to define a variable that indicates the color group, defined as the color of the first retrieval. If there is another retrieval at a later date, the color group will change to the color of the second retrieval, for all remaining iterations, and so on for more retrievals.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data looks as follows:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="57px"&gt;ID&lt;/TD&gt;
&lt;TD width="12.5%" height="57px"&gt;visit&lt;/TD&gt;
&lt;TD width="12.5%" height="57px"&gt;num_retrieved&lt;/TD&gt;
&lt;TD width="12.5%" height="57px"&gt;num_transferred&lt;/TD&gt;
&lt;TD width="12.5%" height="57px"&gt;num_restored&lt;/TD&gt;
&lt;TD width="12.5%" height="57px"&gt;retrieval_interation&lt;/TD&gt;
&lt;TD width="12.5%" height="57px"&gt;color&lt;/TD&gt;
&lt;TD width="12.5%" height="57px"&gt;&lt;FONT color="#FF0000"&gt;group (need)&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;blue&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;blue&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;blue&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;red&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;red&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;4&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;red&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;green&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;green&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;green&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;7&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;5&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;red&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;red&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;4&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;green&lt;/TD&gt;
&lt;TD width="12.5%" height="30px"&gt;green&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if anyone can help me get the group column above, that would be greatly appreciated! Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have; 
    input id visit num_retrieved num_transferred num_restored retrieval_iteration color $; 
    datalines;
1 1 3 2 1 1 blue
1 2 0 1 0 . "" 
1 3 2 0 2 2 red 
1 4 0 0 0 . ""
2 1 0 0 0 . ""
2 2 1 0 1 1 green
2 3 0 1 0 . "" 
3 1 7 2 5 1 red
3 2 2 4 3 2 green
; 
run; 

data have; 
set have; 
if color = '""' then color = ""; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jan 2022 16:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/787999#M251860</guid>
      <dc:creator>awardell</dc:creator>
      <dc:date>2022-01-02T16:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a group category in a dataset with multiple iterations for a single patient?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788000#M251861</link>
      <description>&lt;P&gt;Why does&amp;nbsp;&lt;SPAN&gt;retrieval_interation contain the color values suddenly? Is that a typo?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jan 2022 20:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788000#M251861</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-01-01T20:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a group category in a dataset with multiple iterations for a single patient?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788001#M251862</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input id visit num_retrieved num_transferred num_restored retrieval_iteration color $; 
infile datalines missover;
datalines;
1 1 3 2 1 1 blue 
1 2 0 1 0 .      
1 3 2 0 2 2 red  
1 4 0 0 0 .      
2 1 0 0 0 .      
2 2 1 0 1 1 green
2 3 0 1 0 .      
3 1 7 2 5 1 red  
3 2 2 4 3 2 green
; 

data want;
   set have;
   by id;
   length group $ 8;
   if first.id then group = '';
   if color ne '' then group = color;
   retain group;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jan 2022 20:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788001#M251862</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-01-01T20:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a group category in a dataset with multiple iterations for a single patient?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788030#M251875</link>
      <description>Thank you so much! This works!!! It was a typo above. I will edit it!</description>
      <pubDate>Sun, 02 Jan 2022 16:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788030#M251875</guid>
      <dc:creator>awardell</dc:creator>
      <dc:date>2022-01-02T16:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a group category in a dataset with multiple iterations for a single patient?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788031#M251876</link>
      <description>&lt;P&gt;Note you can use period to mark missing character values also.&amp;nbsp; The normal character informat will convert a single period to blank(s).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datalines;
1 1 3 2 1 1 blue
1 2 0 1 0 . . 
1 3 2 0 2 2 red 
1 4 0 0 0 . .
2 1 0 0 0 . .
2 2 1 0 1 1 green
2 3 0 1 0 . . 
3 1 7 2 5 1 red
3 2 2 4 3 2 green
; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Jan 2022 17:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-group-category-in-a-dataset-with-multiple/m-p/788031#M251876</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-02T17:05:29Z</dc:date>
    </item>
  </channel>
</rss>

