<?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: Select all that apply variable to binary variables in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816283#M511</link>
    <description>&lt;P&gt;You can also loop the other way. Loop over the codes 1 to 14 and check if they are in the list or not.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data binary;
  set have;
  array _covid covid1-covid14 ;
  do index=1 to 14 ;
     _covid[index] = 0 &amp;lt;  indexw(covid,cats(index),', ')  ;
  end;
  drop index;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Jun 2022 01:35:14 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-06-03T01:35:14Z</dc:date>
    <item>
      <title>Select all that apply variable to binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816273#M508</link>
      <description>&lt;P&gt;I have a dataset from a survey where one of the questions was select all that apply. When exported from Qualtrics to Excel, the variable is in this format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Obs&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;Covid&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;1,10,11,12,13,14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;1,12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 16 potential response options. I am stuck how to create binary variables for each response option without hardcoding everything in excel. I ultimately want to determine how many observations selected each response option.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 23:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816273#M508</guid>
      <dc:creator>mraposa1</dc:creator>
      <dc:date>2022-06-02T23:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select all that apply variable to binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816280#M509</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards dsd;
input obs $ COVID : $20.;
cards;
"1", "1,10,11,12,13,14"
"2", "1,12"
;;;;
run;

data binary;
set have;

nwords = countw(covid);

array _covid(14) covid1-covid14 ;

*set all to 0;
do i=1 to 14;
_covid(i) = 0;
end;

*set to 1 for each value of the COVID variable, ie COVID1=1, COVID10=1, COVID11=1 etc;
do i=1 to nwords;
	index = input(scan(covid, i), 8.);
	_covid(index) = 1;
end;

drop nwords index i;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/426805"&gt;@mraposa1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a dataset from a survey where one of the questions was select all that apply. When exported from Qualtrics to Excel, the variable is in this format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;Obs&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;Covid&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;1,10,11,12,13,14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;1,12&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are 16 potential response options. I am stuck how to create binary variables for each response option without hardcoding everything in excel. I ultimately want to determine how many observations selected each response option.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 00:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816280#M509</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-03T00:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Select all that apply variable to binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816281#M510</link>
      <description>&lt;P&gt;Thank you so much! I appreciate it!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 00:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816281#M510</guid>
      <dc:creator>mraposa1</dc:creator>
      <dc:date>2022-06-03T00:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Select all that apply variable to binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816283#M511</link>
      <description>&lt;P&gt;You can also loop the other way. Loop over the codes 1 to 14 and check if they are in the list or not.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data binary;
  set have;
  array _covid covid1-covid14 ;
  do index=1 to 14 ;
     _covid[index] = 0 &amp;lt;  indexw(covid,cats(index),', ')  ;
  end;
  drop index;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jun 2022 01:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Select-all-that-apply-variable-to-binary-variables/m-p/816283#M511</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-03T01:35:14Z</dc:date>
    </item>
  </channel>
</rss>

