<?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: Create Indicator Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Indicator-Variables/m-p/651302#M195406</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Merged_data3;
Set Merged_data2;
array Drug_list [*] DrugFlag1-DrugFlag48;
opoid_flg = 0; benzo_flg=0;
do over drug_list;
&amp;nbsp; &amp;nbsp;if index(upcase(drug_lst),'OPIOD') then&amp;nbsp;opoid_flg =1;&amp;nbsp;
&amp;nbsp; &amp;nbsp;if index(upcase(drug_lst),'BENZO') then benzo_flg =1;&amp;nbsp;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 28 May 2020 06:55:51 GMT</pubDate>
    <dc:creator>DavePrinsloo</dc:creator>
    <dc:date>2020-05-28T06:55:51Z</dc:date>
    <item>
      <title>Create Indicator Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Indicator-Variables/m-p/651293#M195397</link>
      <description>&lt;P&gt;I am trying to create a variable using an array statement. I have a dataset with variables Drug1 - Drug48. The drugs include opioid, benzo, anticholinergic and antibiotics. I want to create 3 new variables that are Opioid, benzo and anticholinergic will be " yes" or "no" . I need help. I tried using this code below but it did not help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA Merged_data3;&lt;BR /&gt;Set Merged_data2;&lt;BR /&gt;array Drug_list [*] DrugFlag1-DrugFlag48;&lt;BR /&gt;All_Drugs= catx(' ', of Drug_list[*]);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 06:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Indicator-Variables/m-p/651293#M195397</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2020-05-28T06:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create Indicator Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Indicator-Variables/m-p/651302#M195406</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Merged_data3;
Set Merged_data2;
array Drug_list [*] DrugFlag1-DrugFlag48;
opoid_flg = 0; benzo_flg=0;
do over drug_list;
&amp;nbsp; &amp;nbsp;if index(upcase(drug_lst),'OPIOD') then&amp;nbsp;opoid_flg =1;&amp;nbsp;
&amp;nbsp; &amp;nbsp;if index(upcase(drug_lst),'BENZO') then benzo_flg =1;&amp;nbsp;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 May 2020 06:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Indicator-Variables/m-p/651302#M195406</guid>
      <dc:creator>DavePrinsloo</dc:creator>
      <dc:date>2020-05-28T06:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create Indicator Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Indicator-Variables/m-p/651303#M195407</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319831"&gt;@UcheOkoro&lt;/a&gt; you question is not clear, you said you want to create 3 new variables but its not clear. However if you want to concatenate all the drugs in drug1-drug48 variables then you can do as below with arrays&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set merged_data2;
array drug_list(*) $ drugflag1-drugflag48;
array drug_name(*) $ drugnam1-drugnam48;
do i = 1 to dim(drug_list);
if drug_list(i)='Y' then drug_name(i)=vname(drug_name(i));
if drug_name(i)='opioid' the opioid='Yes';
if drug_name(i)='benzo' the benzo='Yes';
if drug_name(i)='anticholinergic' the anticholinergic='Yes';
end;&lt;BR /&gt;all_drugs=catx(' ', of Drug_nam[*]);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 May 2020 06:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Indicator-Variables/m-p/651303#M195407</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-05-28T06:59:27Z</dc:date>
    </item>
  </channel>
</rss>

