<?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 Fill records based on occurrences in/out of a range in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Fill-records-based-on-occurrences-in-out-of-a-range/m-p/951617#M42765</link>
    <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following:&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 DB;
  input ID :$20. Admission :date09. Discharge :date09. Age_classStart Age_classEnd; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 5  8
0001 21FEB2015 31DEC2015 5  8
0001 01MAR2018 30SEP2018 6  8
0001 01JAN2019 31DEC2019 6  8
0002 01JAN2015 31DEC2015 1  3
0002 01JAN2019 31OCT2019 3  3
0003 08FEB2014 10MAR2014 6  9
0003 16JUN2015 13JUL2015 6  9
0004 04MAY2016 10MAY2016 4  6
0004 13SEP2017 15NOV2017 4  6
0004 09DEC2018 31DEC2018 5  6
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to get the following?&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. Admission :date09. Discharge :date09. Age_class1 Age_class2 Age_class3 Age_class4 Age_class5 Age_class6 Age_class7 Age_class8 Age_class9; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 . . . . 1 1 1 1 .
0001 21FEB2015 31DEC2015 . . . . 1 1 1 1 .
0001 01MAR2018 30SEP2018 . . . . . 1 1 1 .
0001 01JAN2019 31DEC2019 . . . . . 1 1 1 .
0002 01JAN2015 31DEC2015 1 1 1 . . . . . .
0002 01JAN2019 31OCT2019 . . 1 . . . . . .
0003 08FEB2014 10MAR2014 . . . . . 1 1 1 1
0003 16JUN2015 13JUL2015 . . . . . 1 1 1 1
0004 04MAY2016 10MAY2016 . . . 1 1 1 . . .
0004 13SEP2017 15NOV2017 . . . 1 1 1 . . .
0004 09DEC2018 31DEC2018 . . . . 1 1 . . .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In other word given the Age_classStart and Age_classEnd range, if out of the range set missing otherwise 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Nov 2024 14:18:01 GMT</pubDate>
    <dc:creator>NewUsrStat</dc:creator>
    <dc:date>2024-11-22T14:18:01Z</dc:date>
    <item>
      <title>Fill records based on occurrences in/out of a range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-records-based-on-occurrences-in-out-of-a-range/m-p/951617#M42765</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following:&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 DB;
  input ID :$20. Admission :date09. Discharge :date09. Age_classStart Age_classEnd; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 5  8
0001 21FEB2015 31DEC2015 5  8
0001 01MAR2018 30SEP2018 6  8
0001 01JAN2019 31DEC2019 6  8
0002 01JAN2015 31DEC2015 1  3
0002 01JAN2019 31OCT2019 3  3
0003 08FEB2014 10MAR2014 6  9
0003 16JUN2015 13JUL2015 6  9
0004 04MAY2016 10MAY2016 4  6
0004 13SEP2017 15NOV2017 4  6
0004 09DEC2018 31DEC2018 5  6
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to get the following?&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. Admission :date09. Discharge :date09. Age_class1 Age_class2 Age_class3 Age_class4 Age_class5 Age_class6 Age_class7 Age_class8 Age_class9; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 . . . . 1 1 1 1 .
0001 21FEB2015 31DEC2015 . . . . 1 1 1 1 .
0001 01MAR2018 30SEP2018 . . . . . 1 1 1 .
0001 01JAN2019 31DEC2019 . . . . . 1 1 1 .
0002 01JAN2015 31DEC2015 1 1 1 . . . . . .
0002 01JAN2019 31OCT2019 . . 1 . . . . . .
0003 08FEB2014 10MAR2014 . . . . . 1 1 1 1
0003 16JUN2015 13JUL2015 . . . . . 1 1 1 1
0004 04MAY2016 10MAY2016 . . . 1 1 1 . . .
0004 13SEP2017 15NOV2017 . . . 1 1 1 . . .
0004 09DEC2018 31DEC2018 . . . . 1 1 . . .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In other word given the Age_classStart and Age_classEnd range, if out of the range set missing otherwise 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 14:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-records-based-on-occurrences-in-out-of-a-range/m-p/951617#M42765</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-11-22T14:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fill records based on occurrences in/out of a range</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-records-based-on-occurrences-in-out-of-a-range/m-p/951667#M42766</link>
      <description>&lt;P&gt;You could use an array:&lt;/P&gt;
&lt;P&gt;data DB;&lt;BR /&gt;&amp;nbsp; set DB;&lt;BR /&gt;&amp;nbsp; array AgeClass{9} Age_class1 - Age_class9;&lt;BR /&gt;&amp;nbsp; do i=1 to 9;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if Age_classStart LE i LE Age_classEnd then AgeClass{i}=1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else AgeClass{i}=.;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; drop i;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;This would give you the missing values and 1's. If you wanted 1's and 0's, change the DO loop to&lt;/P&gt;
&lt;P&gt;do i=1 to 9;&lt;BR /&gt;&amp;nbsp; AgeClass{i}= Age_classStart LE i LE Age_classEnd;&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 18:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-records-based-on-occurrences-in-out-of-a-range/m-p/951667#M42766</guid>
      <dc:creator>Zard</dc:creator>
      <dc:date>2024-11-22T18:35:08Z</dc:date>
    </item>
  </channel>
</rss>

