<?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: Converting Multi-Select Variable to Multi-Variable in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-Multi-Select-Variable-to-Multi-Variable/m-p/833659#M20580</link>
    <description>&lt;P&gt;Please save us some headaches and paste example data at least as TEXT in a text box. Open a box using the &amp;lt;/&amp;gt; icon above the message window and paste text. It is not clear whether any of those rows wrap or not so I am not going to guess. It also appears that perhaps the | is not consistent as this line:&lt;/P&gt;
&lt;PRE&gt;Child Protective Services Involvement|History of Treatment for Substance UseHistory of Domestic Violence|(blank)&lt;/PRE&gt;
&lt;P&gt;as I would expect a | between "Use" and "History".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on systems collecting the data you may be able to select a different export approach that places such into separate variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing exactly how many variables/values to work with I might use a series of statements like&lt;/P&gt;
&lt;PRE&gt;CPSInvolve = (index(saepsoes_eosoe_stress,"Child Protective Services Involvement")&amp;gt;0 );&lt;/PRE&gt;
&lt;P&gt;The index function returns the first position a string is found in the target or 0 if not found. SAS will treat the comparison above and return a numeric 1 for true or 0 for false if found. Note that this approach is not going to care about the delimiter as it is searching for specific values. So spelling is critical. Actually you would only need to search for enough characters to uniquely identify the value out of the possible. So it may be that you only need "Child Protective"&lt;/P&gt;
&lt;P&gt;The question does come down to things like are "History of Treatment for Substance Use" supposed to imply "History of Substance Use" if the later is not explicitly included?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So I have a multi-select variable and in sas the value is the selected list of values delimited by a | (the example below is from a PROC FREQ on this variable).&lt;/P&gt;
&lt;P&gt;What I am needing is to break each of these out into separate variables so that I can analyze these stress factors individually.&lt;/P&gt;
&lt;P&gt;The solutions I've found don't accurately reflect the data I have, when I compare them it misses some of the factors.&lt;/P&gt;
&lt;P&gt;In the below example of data, I've only been able to get two CPS involvement and 1 History of DV for example.&lt;/P&gt;
&lt;P&gt;I could use a little guidance here, this part of SAS is really not my strong suit.&amp;nbsp; I'm working in SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;DIV align="center"&gt;saepsoes_eosoe_stres &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/DIV&gt;
&lt;DIV align="center"&gt;Child Protective Services Involvement|History of Substance Use|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;Child Protective Services Involvement|History of Treatment for Substance UseHistory of Domestic Violence|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Domestic Violence|Child Protective Services Involvement|History of Substance Use|&lt;/DIV&gt;
&lt;DIV align="center"&gt;Unemployment|History of Treatment for Substance Use|History of Childhood Trauma|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Domestic Violence|Child Protective Services Involvement|History of Substance Use|Unemployment|&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Treatment for Substance Use|Prior Suicide Attempts|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Domestic Violence|History of Psychiatric Hospitalizations or Treatment|OtherHistory of Domestic Violence|Recent Trauma|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Psychiatric Hospitalizations or Treatment|Child Protective Services Involvement|History of Substance Use|Unemployment|History of Treatment for Substance Use|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Psychiatric Hospitalizations or Treatment|Child Protective Services Involvement|History of Substance Use|Unemployment|Other&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Substance UseHistory of Substance Use|Other|(blank)&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2022 16:13:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-09-15T16:13:43Z</dc:date>
    <item>
      <title>Converting Multi-Select Variable to Multi-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-Multi-Select-Variable-to-Multi-Variable/m-p/833649#M20579</link>
      <description>&lt;P&gt;So I have a multi-select variable and in sas the value is the selected list of values delimited by a | (the example below is from a PROC FREQ on this variable).&lt;/P&gt;&lt;P&gt;What I am needing is to break each of these out into separate variables so that I can analyze these stress factors individually.&lt;/P&gt;&lt;P&gt;The solutions I've found don't accurately reflect the data I have, when I compare them it misses some of the factors.&lt;/P&gt;&lt;P&gt;In the below example of data, I've only been able to get two CPS involvement and 1 History of DV for example.&lt;/P&gt;&lt;P&gt;I could use a little guidance here, this part of SAS is really not my strong suit.&amp;nbsp; I'm working in SAS 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV align="center"&gt;saepsoes_eosoe_stres &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/DIV&gt;&lt;DIV align="center"&gt;Child Protective Services Involvement|History of Substance Use|(blank)&lt;/DIV&gt;&lt;DIV align="center"&gt;Child Protective Services Involvement|History of Treatment for Substance UseHistory of Domestic Violence|(blank)&lt;/DIV&gt;&lt;DIV align="center"&gt;History of Domestic Violence|Child Protective Services Involvement|History of Substance Use|&lt;/DIV&gt;&lt;DIV align="center"&gt;Unemployment|History of Treatment for Substance Use|History of Childhood Trauma|(blank)&lt;/DIV&gt;&lt;DIV align="center"&gt;History of Domestic Violence|Child Protective Services Involvement|History of Substance Use|Unemployment|&lt;/DIV&gt;&lt;DIV align="center"&gt;History of Treatment for Substance Use|Prior Suicide Attempts|(blank)&lt;/DIV&gt;&lt;DIV align="center"&gt;History of Domestic Violence|History of Psychiatric Hospitalizations or Treatment|OtherHistory of Domestic Violence|Recent Trauma|(blank)&lt;/DIV&gt;&lt;DIV align="center"&gt;History of Psychiatric Hospitalizations or Treatment|Child Protective Services Involvement|History of Substance Use|Unemployment|History of Treatment for Substance Use|(blank)&lt;/DIV&gt;&lt;DIV align="center"&gt;History of Psychiatric Hospitalizations or Treatment|Child Protective Services Involvement|History of Substance Use|Unemployment|Other&lt;/DIV&gt;&lt;DIV align="center"&gt;History of Substance UseHistory of Substance Use|Other|(blank)&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 15 Sep 2022 15:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-Multi-Select-Variable-to-Multi-Variable/m-p/833649#M20579</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2022-09-15T15:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Multi-Select Variable to Multi-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-Multi-Select-Variable-to-Multi-Variable/m-p/833659#M20580</link>
      <description>&lt;P&gt;Please save us some headaches and paste example data at least as TEXT in a text box. Open a box using the &amp;lt;/&amp;gt; icon above the message window and paste text. It is not clear whether any of those rows wrap or not so I am not going to guess. It also appears that perhaps the | is not consistent as this line:&lt;/P&gt;
&lt;PRE&gt;Child Protective Services Involvement|History of Treatment for Substance UseHistory of Domestic Violence|(blank)&lt;/PRE&gt;
&lt;P&gt;as I would expect a | between "Use" and "History".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on systems collecting the data you may be able to select a different export approach that places such into separate variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing exactly how many variables/values to work with I might use a series of statements like&lt;/P&gt;
&lt;PRE&gt;CPSInvolve = (index(saepsoes_eosoe_stress,"Child Protective Services Involvement")&amp;gt;0 );&lt;/PRE&gt;
&lt;P&gt;The index function returns the first position a string is found in the target or 0 if not found. SAS will treat the comparison above and return a numeric 1 for true or 0 for false if found. Note that this approach is not going to care about the delimiter as it is searching for specific values. So spelling is critical. Actually you would only need to search for enough characters to uniquely identify the value out of the possible. So it may be that you only need "Child Protective"&lt;/P&gt;
&lt;P&gt;The question does come down to things like are "History of Treatment for Substance Use" supposed to imply "History of Substance Use" if the later is not explicitly included?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So I have a multi-select variable and in sas the value is the selected list of values delimited by a | (the example below is from a PROC FREQ on this variable).&lt;/P&gt;
&lt;P&gt;What I am needing is to break each of these out into separate variables so that I can analyze these stress factors individually.&lt;/P&gt;
&lt;P&gt;The solutions I've found don't accurately reflect the data I have, when I compare them it misses some of the factors.&lt;/P&gt;
&lt;P&gt;In the below example of data, I've only been able to get two CPS involvement and 1 History of DV for example.&lt;/P&gt;
&lt;P&gt;I could use a little guidance here, this part of SAS is really not my strong suit.&amp;nbsp; I'm working in SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;DIV align="center"&gt;saepsoes_eosoe_stres &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/DIV&gt;
&lt;DIV align="center"&gt;Child Protective Services Involvement|History of Substance Use|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;Child Protective Services Involvement|History of Treatment for Substance UseHistory of Domestic Violence|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Domestic Violence|Child Protective Services Involvement|History of Substance Use|&lt;/DIV&gt;
&lt;DIV align="center"&gt;Unemployment|History of Treatment for Substance Use|History of Childhood Trauma|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Domestic Violence|Child Protective Services Involvement|History of Substance Use|Unemployment|&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Treatment for Substance Use|Prior Suicide Attempts|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Domestic Violence|History of Psychiatric Hospitalizations or Treatment|OtherHistory of Domestic Violence|Recent Trauma|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Psychiatric Hospitalizations or Treatment|Child Protective Services Involvement|History of Substance Use|Unemployment|History of Treatment for Substance Use|(blank)&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Psychiatric Hospitalizations or Treatment|Child Protective Services Involvement|History of Substance Use|Unemployment|Other&lt;/DIV&gt;
&lt;DIV align="center"&gt;History of Substance UseHistory of Substance Use|Other|(blank)&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 16:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-Multi-Select-Variable-to-Multi-Variable/m-p/833659#M20580</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-15T16:13:43Z</dc:date>
    </item>
  </channel>
</rss>

