<?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 Stack multiple modalities attributes based on multiple events in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Stack-multiple-modalities-attributes-based-on-multiple-events/m-p/811271#M319970</link>
    <description>&lt;P&gt;I have the following dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data have;
infile datalines delimiter="|";
input attrib :$30. multiple_attr :$1. id :$30. attrib_id :8. member_value :$100. type :$5. dt_event :datetime18.;
format dt_event datetime20.;
datalines;
TYPE|N|ABC123|111|MEDIUM|Start|01DEC2014:00:00:00
TYPE|N|ABC123|111|MEDIUM|End|18APR2021:00:00:00
TYPE|N|ABC123|111|BIG|Start|19APR2021:00:00:00
TYPE|N|ABC123|111|BIG|End|31DEC2030:00:00:00
POSITION|N|ABC123|222|TOP|Start|01DEC2014:00:00:00
POSITION|N|ABC123|222|TOP|End|31DEC2030:00:00:00
IS_ACTIVE|N|ABC123|333|YES|Start|01DEC2014:00:00:00
IS_ACTIVE|N|ABC123|333|YES|End|31DEC2030:00:00:00
LEVELS|Y|ABC123|1|ALONE|Start|01DEC2014:00:00:00
LEVELS|Y|ABC123|1|BOTH|Start|01DEC2014:00:00:00
LEVELS|Y|ABC123|1|BOTH|End|18APR2021:00:00:00
LEVELS|Y|ABC123|1|ALONE|End|31DEC2030:00:00:00
TYPE|N|DEF456|111|MEDIUM|Start|01DEC2014:00:00:00
TYPE|N|DEF456|111|MEDIUM|End|31DEC2030:00:00:00
POSITION|N|DEF456|222|MID|Start|01DEC2014:00:00:00
POSITION|N|DEF456|222|MID|End|31DEC2030:00:00:00
IS_ACTIVE|N|DEF456|333|YES|Start|01MAR2014:00:00:00
IS_ACTIVE|N|DEF456|333|YES|End|31DEC2030:00:00:00
LEVELS|Y|DEF456|1|ALONE|Start|01MAR2014:00:00:00
LEVELS|Y|DEF456|1|BOTH|Start|01MAR2014:00:00:00
LEVELS|Y|DEF456|1|BOTH|End|31MAR2018:00:00:00
LEVELS|Y|DEF456|1|BOTH|Start|20AUG2018:00:00:00
LEVELS|Y|DEF456|1|ALONE|End|31DEC2030:00:00:00
LEVELS|Y|DEF456|1|BOTH|End|31DEC2030:00:00:00
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is a event based table for all the attributes an ID has.&lt;/P&gt;&lt;P&gt;I would like to be able to "stack" multiple modalities attributes (ex: stacj attrib_id 1 together) so that I end up with the following dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;+---------------+--------+-----------+--------------------+--------------------+--------------+
| multiple_attr |   id   | attrib_id |     start_date     |      end_date      | member_value |
+---------------+--------+-----------+--------------------+--------------------+--------------+
| Y             | ABC123 |         1 | 01DEC2014:00:00:00 | 18APR2021:00:00:00 | ALONE; BOTH  |
| Y             | ABC123 |         1 | 19APR2021:00:00:00 | 31DEC2030:00:00:00 | ALONE        |
| N             | ABC123 |       111 | 01DEC2014:00:00:00 | 18APR2021:00:00:00 | MEDIUM       |
| N             | ABC123 |       111 | 19APR2021:00:00:00 | 31DEC2030:00:00:00 | BIG          |
| N             | ABC123 |       222 | 01DEC2014:00:00:00 | 31DEC2030:00:00:00 | TOP          |
| N             | ABC123 |       333 | 01DEC2014:00:00:00 | 31DEC2030:00:00:00 | YES          |
| Y             | DEF456 |         1 | 01MAR2014:00:00:00 | 31MAR2018:00:00:00 | ALONE; BOTH  |
| Y             | DEF456 |         1 | 01APR2018:00:00:00 | 19AUG2018:00:00:00 | ALONE        |
| Y             | DEF456 |         1 | 20AUG2018:00:00:00 | 31DEC2030:00:00:00 | ALONE; BOTH  |
| N             | DEF456 |       111 | 01DEC2014:00:00:00 | 31DEC2030:00:00:00 | MEDIUM       |
| N             | DEF456 |       222 | 01DEC2014:00:00:00 | 31DEC2030:00:00:00 | MID          |
| N             | DEF456 |       333 | 01MAR2014:00:00:00 | 31DEC2030:00:00:00 | YES          |
+---------------+--------+-----------+--------------------+--------------------+--------------+&lt;/PRE&gt;&lt;P&gt;Is there a way to do this?&lt;/P&gt;</description>
    <pubDate>Tue, 03 May 2022 16:23:01 GMT</pubDate>
    <dc:creator>legends1337</dc:creator>
    <dc:date>2022-05-03T16:23:01Z</dc:date>
    <item>
      <title>Stack multiple modalities attributes based on multiple events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stack-multiple-modalities-attributes-based-on-multiple-events/m-p/811271#M319970</link>
      <description>&lt;P&gt;I have the following dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data have;
infile datalines delimiter="|";
input attrib :$30. multiple_attr :$1. id :$30. attrib_id :8. member_value :$100. type :$5. dt_event :datetime18.;
format dt_event datetime20.;
datalines;
TYPE|N|ABC123|111|MEDIUM|Start|01DEC2014:00:00:00
TYPE|N|ABC123|111|MEDIUM|End|18APR2021:00:00:00
TYPE|N|ABC123|111|BIG|Start|19APR2021:00:00:00
TYPE|N|ABC123|111|BIG|End|31DEC2030:00:00:00
POSITION|N|ABC123|222|TOP|Start|01DEC2014:00:00:00
POSITION|N|ABC123|222|TOP|End|31DEC2030:00:00:00
IS_ACTIVE|N|ABC123|333|YES|Start|01DEC2014:00:00:00
IS_ACTIVE|N|ABC123|333|YES|End|31DEC2030:00:00:00
LEVELS|Y|ABC123|1|ALONE|Start|01DEC2014:00:00:00
LEVELS|Y|ABC123|1|BOTH|Start|01DEC2014:00:00:00
LEVELS|Y|ABC123|1|BOTH|End|18APR2021:00:00:00
LEVELS|Y|ABC123|1|ALONE|End|31DEC2030:00:00:00
TYPE|N|DEF456|111|MEDIUM|Start|01DEC2014:00:00:00
TYPE|N|DEF456|111|MEDIUM|End|31DEC2030:00:00:00
POSITION|N|DEF456|222|MID|Start|01DEC2014:00:00:00
POSITION|N|DEF456|222|MID|End|31DEC2030:00:00:00
IS_ACTIVE|N|DEF456|333|YES|Start|01MAR2014:00:00:00
IS_ACTIVE|N|DEF456|333|YES|End|31DEC2030:00:00:00
LEVELS|Y|DEF456|1|ALONE|Start|01MAR2014:00:00:00
LEVELS|Y|DEF456|1|BOTH|Start|01MAR2014:00:00:00
LEVELS|Y|DEF456|1|BOTH|End|31MAR2018:00:00:00
LEVELS|Y|DEF456|1|BOTH|Start|20AUG2018:00:00:00
LEVELS|Y|DEF456|1|ALONE|End|31DEC2030:00:00:00
LEVELS|Y|DEF456|1|BOTH|End|31DEC2030:00:00:00
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is a event based table for all the attributes an ID has.&lt;/P&gt;&lt;P&gt;I would like to be able to "stack" multiple modalities attributes (ex: stacj attrib_id 1 together) so that I end up with the following dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;+---------------+--------+-----------+--------------------+--------------------+--------------+
| multiple_attr |   id   | attrib_id |     start_date     |      end_date      | member_value |
+---------------+--------+-----------+--------------------+--------------------+--------------+
| Y             | ABC123 |         1 | 01DEC2014:00:00:00 | 18APR2021:00:00:00 | ALONE; BOTH  |
| Y             | ABC123 |         1 | 19APR2021:00:00:00 | 31DEC2030:00:00:00 | ALONE        |
| N             | ABC123 |       111 | 01DEC2014:00:00:00 | 18APR2021:00:00:00 | MEDIUM       |
| N             | ABC123 |       111 | 19APR2021:00:00:00 | 31DEC2030:00:00:00 | BIG          |
| N             | ABC123 |       222 | 01DEC2014:00:00:00 | 31DEC2030:00:00:00 | TOP          |
| N             | ABC123 |       333 | 01DEC2014:00:00:00 | 31DEC2030:00:00:00 | YES          |
| Y             | DEF456 |         1 | 01MAR2014:00:00:00 | 31MAR2018:00:00:00 | ALONE; BOTH  |
| Y             | DEF456 |         1 | 01APR2018:00:00:00 | 19AUG2018:00:00:00 | ALONE        |
| Y             | DEF456 |         1 | 20AUG2018:00:00:00 | 31DEC2030:00:00:00 | ALONE; BOTH  |
| N             | DEF456 |       111 | 01DEC2014:00:00:00 | 31DEC2030:00:00:00 | MEDIUM       |
| N             | DEF456 |       222 | 01DEC2014:00:00:00 | 31DEC2030:00:00:00 | MID          |
| N             | DEF456 |       333 | 01MAR2014:00:00:00 | 31DEC2030:00:00:00 | YES          |
+---------------+--------+-----------+--------------------+--------------------+--------------+&lt;/PRE&gt;&lt;P&gt;Is there a way to do this?&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 16:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stack-multiple-modalities-attributes-based-on-multiple-events/m-p/811271#M319970</guid>
      <dc:creator>legends1337</dc:creator>
      <dc:date>2022-05-03T16:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Stack multiple modalities attributes based on multiple events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stack-multiple-modalities-attributes-based-on-multiple-events/m-p/811467#M320070</link>
      <description>&lt;P&gt;This sounds like a job for PROC TRANSPOSE, but the logic behind "stacking multiple modalities attributes" is not clear.&amp;nbsp;Can you walk through, in explicit detail, the logic for how attributes are to be "stacked" and which rows should be combined?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you thoroughly confirm that your input dataset is complete and correct for deriving your output dataset? If not, please revise as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That being said, a few starter questions about your&amp;nbsp;output dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;- Where did the Aug 19, 2018 &lt;EM&gt;end_date&lt;/EM&gt; come from? I don't see that in your input dataset. Was it derived somehow?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;- For&amp;nbsp;&lt;EM&gt;id&amp;nbsp;&lt;/EM&gt;ABC123,&amp;nbsp;&lt;EM&gt;attrib_id&amp;nbsp;&lt;/EM&gt;1, where did the Apr 19, 2021&amp;nbsp;&lt;EM&gt;start_date&amp;nbsp;&lt;/EM&gt;come from?&amp;nbsp;I don't see that in your input dataset. Was it derived somehow?&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 14:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stack-multiple-modalities-attributes-based-on-multiple-events/m-p/811467#M320070</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2022-05-04T14:43:06Z</dc:date>
    </item>
  </channel>
</rss>

