<?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: Split a variable and assign the contribution of IDs to that variable values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951466#M42761</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 want(drop = i);
   set DB;
   array a {8} Age_class1 - Age_class8;
   do i = 1 to dim(a);
      a[i] = Index = 1;
      if Index = 1 then a[Age_class] = 0;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Nov 2024 13:15:54 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2024-11-21T13:15:54Z</dc:date>
    <item>
      <title>Split a variable and assign the contribution of IDs to that variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951465#M42760</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. Admission :date09. Discharge :date09. Index Age_class; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 1  6
0001 21FEB2015 31DEC2015 0  6
0001 01MAR2018 30SEP2018 0  7
0001 01JAN2019 31DEC2019 0  7
0002 01JAN2015 31DEC2015 1  3
0002 01JAN2019 31OCT2019 0  5
0003 08FEB2014 10MAR2014 1  3
0003 16JUN2015 13JUL2015 0  3
0004 04MAY2016 10MAY2016 1  8
0004 13SEP2017 15NOV2017 0  8
0004 09DEC2018 31DEC2018 0  8
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Age_class takes values from 1 to 8.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to get the following?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$20. Admission :date09. Discharge :date09. Index Age_class Age_class1 Age_class2 Age_class3 .... Age_class7 Age_class8; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 1  6  1  1  1 ... 1  1
0001 21FEB2015 31DEC2015 0  6  0  0  0 ... 0  0
0001 01MAR2018 30SEP2018 0  7  0  0  0 ... 0  0
0001 01JAN2019 31DEC2019 0  7  0  0  0 ... 0  0
0002 01JAN2015 31DEC2015 1  3  1  1  0 ... 1  1
0002 01JAN2019 31OCT2019 0  5  0  0  0 ... 0  0
0003 08FEB2014 10MAR2014 1  3  1  1  0 ... 1  1
0003 16JUN2015 13JUL2015 0  3  0  0  0 ... 0  0
0004 04MAY2016 10MAY2016 1  8  1  1  1 ... 1  0
0004 13SEP2017 15NOV2017 0  8  0  0  0 ... 0  0
0004 09DEC2018 31DEC2018 0  8  0  0  0 ... 0  0
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In other words I need to fill Age_class* variables (Age_class1, Age_class2, ..., Age_class8) with 1 if at Index = 1 the patient IS NOT in that age_class and 0 otherwise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that Index = 1 is always the first date (Admission-Discharge) for each patient and there is always one Index = 1 for each patient.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example: pts 0001 at Index = 1 has Age_class = 6.&amp;nbsp; Age_class1,&amp;nbsp;Age_class2,&amp;nbsp;Age_class3,&amp;nbsp;Age_class4,&amp;nbsp;Age_class5,&amp;nbsp;Age_class7,&amp;nbsp;Age_class8 will be filled with 1 because the patient is not contributing to that age_class while it will be 0 at&amp;nbsp;Age_class6 because it is contributing.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note also, that there are other dates that will be put to 0 because of no interest.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know, I can do "if then else" but it will take a lot of coding to perform all comparisons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your help.&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;P&gt;&amp;nbsp;&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;</description>
      <pubDate>Thu, 21 Nov 2024 13:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951465#M42760</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-11-21T13:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Split a variable and assign the contribution of IDs to that variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951466#M42761</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 want(drop = i);
   set DB;
   array a {8} Age_class1 - Age_class8;
   do i = 1 to dim(a);
      a[i] = Index = 1;
      if Index = 1 then a[Age_class] = 0;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2024 13:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951466#M42761</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2024-11-21T13:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Split a variable and assign the contribution of IDs to that variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951470#M42762</link>
      <description>&lt;P&gt;Maybe I'm not understanding this properly, because the admission dates and discharge dates are not used anywhere. Also maybe I'm not understanding the general problem of creating these zero and 1 variables, why do you need these if you have the value of INDEX? Seems redundant to me, what is the next step after you have these 0 and 1 variables, what will you do with them, what analysis or plot or table are you going to create?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2024 13:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951470#M42762</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-11-21T13:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Split a variable and assign the contribution of IDs to that variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951475#M42763</link>
      <description>Thank you very much for your comment. Yes it is true that there's the variable Age_class but I need to count every time every ID is not contributing to an age class from 1 to 8 except the one to which it belongs. Yes, dates will not be used but are there and I left them to show that Index = 1 at first date.</description>
      <pubDate>Thu, 21 Nov 2024 13:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951475#M42763</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-11-21T13:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Split a variable and assign the contribution of IDs to that variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951479#M42764</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134532"&gt;@NewUsrStat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you very much for your comment. Yes it is true that there's the variable Age_class but I need to count every time every ID is not contributing to an age class from 1 to 8 except the one to which it belongs. Yes, dates will not be used but are there and I left them to show that Index = 1 at first date.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Far too vague of an explanation about what you will do next with this data.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2024 14:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-a-variable-and-assign-the-contribution-of-IDs-to-that/m-p/951479#M42764</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-11-21T14:04:59Z</dc:date>
    </item>
  </channel>
</rss>

