<?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: if-then in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605028#M17158</link>
    <description>&lt;P&gt;I think this is the syntax you're looking for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cdmeds;
    set ndc2;
    if NONPROPRIETARYNAME in ('Metronidazole', 'infliximab', 'natalizumab') then do;
        metron=1;
        inflix=1;
        natal=1;
    end;
run;

proc print data=cdmeds;
    var natal inflix metron;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Nov 2019 14:58:05 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-18T14:58:05Z</dc:date>
    <item>
      <title>if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605027#M17157</link>
      <description>&lt;P&gt;Hi Sas user,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to assign prescription variables as 1 in this code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data cdmeds;&lt;BR /&gt;set ndc2;&lt;BR /&gt;if NONPROPRIETARYNAME = 'Metronidazole' or 'infliximab' or 'natalizumab' then do;&lt;BR /&gt;metron=1;&lt;BR /&gt;inflix=1;&lt;BR /&gt;natal=1;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;proc print data=cdmeds;&lt;BR /&gt;var natal inflix metron;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, my log appears like this with all missing values (see attachment). What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605027#M17157</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-11-18T14:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605028#M17158</link>
      <description>&lt;P&gt;I think this is the syntax you're looking for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cdmeds;
    set ndc2;
    if NONPROPRIETARYNAME in ('Metronidazole', 'infliximab', 'natalizumab') then do;
        metron=1;
        inflix=1;
        natal=1;
    end;
run;

proc print data=cdmeds;
    var natal inflix metron;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605028#M17158</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-18T14:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605033#M17160</link>
      <description>&lt;P&gt;Thank you for your suggestion, but it still did not work.&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605033#M17160</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-11-18T15:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605034#M17161</link>
      <description>&lt;P&gt;I can't see your data or your log. Only your code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post your log.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605034#M17161</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-18T15:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: if-then log</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605039#M17162</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34058i98073B71C73A6F9C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605039#M17162</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-11-18T15:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605041#M17164</link>
      <description>&lt;P&gt;see picture below!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:19:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605041#M17164</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-11-18T15:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605043#M17165</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299242"&gt;@nturne&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe try this (it seems more logical according to the variables names but I am not sure as I can't see your raw data)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data cdmeds;
	set ndc2;

	if lowcase(NONPROPRIETARYNAME)='metronidazole' then metron=1;
	else if lowcase(NONPROPRIETARYNAME)='infliximab' then inflix=1;
	else if lowcase(NONPROPRIETARYNAME)='natalizumab' then natal=1;

run;

proc print data=cdmeds;
	var metron inflix natal;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605043#M17165</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-18T15:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605044#M17166</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299242"&gt;@nturne&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your suggestion, but it still did not work.&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please don't feed us the proverbial "blonde secretary" quotes.&lt;/P&gt;
&lt;P&gt;Post the LOG (using the {I} button), and post example data as a data step with datalines. DO NOT post pictures of data, we're not hired as your typists.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605044#M17166</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-18T15:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605047#M17167</link>
      <description>&lt;P&gt;This is your result data, not your log. Please don't make us guess the structure of your data.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605047#M17167</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-18T15:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605055#M17169</link>
      <description>&lt;P&gt;NOTE: There were 193176 observations read from the data set WORK.CDMEDS.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.47 seconds&lt;BR /&gt;cpu time 0.48 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;180 data cdmeds;&lt;BR /&gt;181 set ndc2;&lt;BR /&gt;182 if NONPROPRIETARYNAME in ('metronidazole', 'infliximab' , 'natalizumab') then do;&lt;BR /&gt;183 metron=1;&lt;BR /&gt;184 inflix=1;&lt;BR /&gt;185 natal=1;&lt;BR /&gt;186 end;&lt;BR /&gt;187 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 193176 observations read from the data set WORK.NDC2.&lt;BR /&gt;NOTE: The data set WORK.CDMEDS has 193176 observations and 29 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.34 seconds&lt;BR /&gt;cpu time 0.32 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;188&lt;BR /&gt;189 proc print data=cdmeds;&lt;BR /&gt;190 var metron natal inflix;&lt;BR /&gt;191 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 193176 observations read from the data set WORK.CDMEDS.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.57 seconds&lt;BR /&gt;cpu time 0.57 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;192 ***Re&lt;/P&gt;&lt;P&gt;193 data cdmeds;&lt;BR /&gt;194 set ndc2;&lt;BR /&gt;195&lt;BR /&gt;196 if lowcase(NONPROPRIETARYNAME) = 'metronidazole' then metron=1;&lt;BR /&gt;197 else if lowcase(NONPROPRIETARYNAME) = 'infliximab' then inflix=1;&lt;BR /&gt;198 else if lowcase(NONPROPRIETARYNAME) = 'natalizumab' then natal=1;&lt;BR /&gt;199&lt;/P&gt;&lt;P&gt;NOTE: There were 193176 observations read from the data set WORK.NDC2.&lt;BR /&gt;NOTE: The data set WORK.CDMEDS has 193176 observations and 29 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.37 seconds&lt;BR /&gt;cpu time 0.36 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;200 proc print data=cdmeds;&lt;BR /&gt;201 var natal inflix metron;&lt;BR /&gt;202 run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my log. Although, there is no error message, I still do not have any values in my output.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605055#M17169</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-11-18T15:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605060#M17170</link>
      <description>&lt;P&gt;Add this into your case statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could be that your proc print isn't printing enough observations to view a hit. This will show you for sure that something (or nothing) is being identified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-unison&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605060#M17170</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-18T15:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605069#M17171</link>
      <description>&lt;P&gt;The same using an array an more practical if you have a long list of drugs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data cdmeds;

	set ndc2;

	array presc(3) $20  ('metronidazole','infliximab','natalizumab'); /* specify the list of drugs */
	array flag(3) metron inflix natal; /* specify the list of associated flags in the same order */
	
	do i=1 to dim(presc);
		if index(lowcase(nonproprietaryname),presc(i))&amp;gt;0 then do;
			flag(i)=1;
			leave;
		end;
	end;
	
	drop i;
	
run;

proc print data=cdmeds;
	var metron inflix natal;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605069#M17171</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-18T15:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605072#M17172</link>
      <description>&lt;P&gt;Add nonproprietaryname to your var list in proc print, to check it.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 16:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605072#M17172</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-18T16:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605074#M17173</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I received the following error:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;361 do i=1 to dim(presc);&lt;BR /&gt;362 if index(nonproprietaryname),presc(i))&amp;gt;0 then do;&lt;BR /&gt;- -&lt;BR /&gt;22 22&lt;BR /&gt;200 200&lt;BR /&gt;-----&lt;BR /&gt;71&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=,&lt;BR /&gt;&amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN,&lt;BR /&gt;OR, THEN, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;ERROR 71-185: The INDEX function call does not have enough arguments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 16:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605074#M17173</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-11-18T16:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605075#M17174</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it seems that lowercase is missing :&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;index&lt;/SPAN&gt;&lt;FONT color="#339966"&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;lowcase&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;/FONT&gt;nonproprietaryname&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;presc&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 16:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605075#M17174</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-18T16:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605082#M17175</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299242"&gt;@nturne&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I received the following error:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;361 do i=1 to dim(presc);&lt;BR /&gt;362 if index(nonproprietaryname),presc(i))&amp;gt;0 then do;&lt;BR /&gt;- -&lt;BR /&gt;22 22&lt;BR /&gt;200 200&lt;BR /&gt;-----&lt;BR /&gt;71&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=,&lt;BR /&gt;&amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN,&lt;BR /&gt;OR, THEN, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;ERROR 71-185: The INDEX function call does not have enough arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Count your opening and closing brackets in line 362.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 16:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605082#M17175</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-18T16:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: if-then</title>
      <link>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605150#M17178</link>
      <description>&lt;P&gt;I apologize if i offended the SAS experts. I am new to sas communities so I'm still learning how to use this. I had no idea we could not take screen shots (note to self).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 18:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/if-then/m-p/605150#M17178</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-11-18T18:46:54Z</dc:date>
    </item>
  </channel>
</rss>

