<?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: Set to value to missing when condition is met in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900235#M355791</link>
    <description>&lt;P&gt;How about this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data screen;
set example;
array d{*} drug:;
do i=1 to dim(d);
    if d{i} in ("thc/carboxy-thc" "thc" "carboxy-thc") and whichc("cannabinoids",of d:) then do;
    do j=1 to dim(d);
       if d(j)="cannabinoids" then call missing(d(j));
    end;
    end;
end;
drop i j;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Oct 2023 21:30:11 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-10-26T21:30:11Z</dc:date>
    <item>
      <title>Set to value to missing when condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900222#M355784</link>
      <description>&lt;P&gt;I am trying to make an array to scan each row and remove 'cannabinoids' when 'thc' 'carboxy-thc' or 'thc/carboxy-thc' are present. An example of the data follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data example;&lt;BR /&gt;input drug1 :&amp;amp; $30. drug2 $30.;&lt;BR /&gt;cards;&lt;BR /&gt;thc cannabinoids&lt;BR /&gt;cannabinoids thc/carboxy-thc&lt;BR /&gt;carboxy-thc cannabinoids&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the direction I was heading, but it does not seem to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data screen;&lt;BR /&gt;set alldrugs09;&lt;BR /&gt;array d{*} drug:;&lt;BR /&gt;do i=1 to dim(d);&lt;BR /&gt;if d{i} in ("thc/carboxy-thc" "thc" "carboxy-thc") then do;&lt;BR /&gt;if d{i}="cannabinoids" then d{i}="";&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;drop i;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 20:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900222#M355784</guid>
      <dc:creator>mrcodes</dc:creator>
      <dc:date>2023-10-26T20:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Set to value to missing when condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900230#M355788</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
input drug1 :&amp;amp; $30. drug2 $30.;
cards;
thc cannabinoids
cannabinoids thc/carboxy-thc
carboxy-thc cannabinoids
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you are expecting two different drug variables, DRUG1 and DRUG2, but your code as written does not produce two different drug values; DRUG2 is always missing. So this needs to be fixed. I can't debug the rest of your code until I have a working version of your data set.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 21:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900230#M355788</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-26T21:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Set to value to missing when condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900231#M355789</link>
      <description>Try this. It looks like when i copied pasted it removed one of the spaces between drug1 and drug2 in the cards.&lt;BR /&gt;&lt;BR /&gt;data example;&lt;BR /&gt;input drug1 :&amp;amp; $30. drug2 $30.;&lt;BR /&gt;cards;&lt;BR /&gt;thc cannabinoids&lt;BR /&gt;cannabinoids thc/carboxy-thc&lt;BR /&gt;carboxy-thc cannabinoids&lt;BR /&gt;;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 26 Oct 2023 21:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900231#M355789</guid>
      <dc:creator>mrcodes</dc:creator>
      <dc:date>2023-10-26T21:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Set to value to missing when condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900232#M355790</link>
      <description>It keeps deleting the second space between drug1 and drug2 in the cards.. should be two spaces when you enter it into SAS</description>
      <pubDate>Thu, 26 Oct 2023 21:16:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900232#M355790</guid>
      <dc:creator>mrcodes</dc:creator>
      <dc:date>2023-10-26T21:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: Set to value to missing when condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900235#M355791</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data screen;
set example;
array d{*} drug:;
do i=1 to dim(d);
    if d{i} in ("thc/carboxy-thc" "thc" "carboxy-thc") and whichc("cannabinoids",of d:) then do;
    do j=1 to dim(d);
       if d(j)="cannabinoids" then call missing(d(j));
    end;
    end;
end;
drop i j;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Oct 2023 21:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900235#M355791</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-26T21:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Set to value to missing when condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900238#M355793</link>
      <description>Yes! It looks like the updated code did work! Thank you!</description>
      <pubDate>Thu, 26 Oct 2023 21:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-to-value-to-missing-when-condition-is-met/m-p/900238#M355793</guid>
      <dc:creator>mrcodes</dc:creator>
      <dc:date>2023-10-26T21:31:53Z</dc:date>
    </item>
  </channel>
</rss>

