<?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: Help with if-then statement in macro in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616601#M18648</link>
    <description>Your logic and code don't match at all so I'm having a hard time understanding which to fix here. &lt;BR /&gt;&lt;BR /&gt;What are you trying to do overall? What makes you think you need a macro in the first place as well - this type of logic is usually best done via a format or SELECT statement, not a macro but hard to confirm that without knowing more.</description>
    <pubDate>Fri, 10 Jan 2020 20:36:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-01-10T20:36:39Z</dc:date>
    <item>
      <title>Help with if-then statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616593#M18644</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;The following code doesn't work. I'm wondering if someone could suggest a fix.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Note: I am trying to mimic an if-then statement with basically two conditions, e.g., if x then 1, if y then 2, else z. ..I can't figure out how to get it to do that as I'm not as proficient in macros.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%if &amp;amp;trim=0 %then %do;&lt;BR /&gt;%let condition = %str(if myvars(i)&amp;lt; perct1(i) then myvars(i)=perct1(i) );&lt;BR /&gt;%let condition = %str(if myvars(i)&amp;gt; perct2(i) then myvars(i)=perct2(i));&lt;BR /&gt;%end;&lt;BR /&gt;%else %let condition = %str(myvars(i)=min(perct2(i),max(perct1(i),myvars(i))) );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 20:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616593#M18644</guid>
      <dc:creator>Megan2020</dc:creator>
      <dc:date>2020-01-10T20:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if-then statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616601#M18648</link>
      <description>Your logic and code don't match at all so I'm having a hard time understanding which to fix here. &lt;BR /&gt;&lt;BR /&gt;What are you trying to do overall? What makes you think you need a macro in the first place as well - this type of logic is usually best done via a format or SELECT statement, not a macro but hard to confirm that without knowing more.</description>
      <pubDate>Fri, 10 Jan 2020 20:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616601#M18648</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-10T20:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if-then statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616603#M18649</link>
      <description>It's someone else' macro I'm trying to fix. Here's the entire macro&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://wrds-www.wharton.upenn.edu/pages/support/research-wrds/macros/wrds-macros-winsorize/#example" target="_blank"&gt;https://wrds-www.wharton.upenn.edu/pages/support/research-wrds/macros/wrds-macros-winsorize/#example&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need the by group functionality and his is the only one I can find that works for that but it only works for trimming TRIM=1 because I think he's missing code for TRIM=0.&lt;BR /&gt;&lt;BR /&gt;That's what my few lines were trying to add.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for any help. Much appreciated.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Jan 2020 20:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616603#M18649</guid>
      <dc:creator>Megan2020</dc:creator>
      <dc:date>2020-01-10T20:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help with if-then statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616607#M18650</link>
      <description>&lt;P&gt;That %IF/%THEN/%ELSE is just being used to stuff some SAS code into a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the problem that you want to stuff two SAS statements into the macro variable CONDITION when is TRIM is set to 0?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just add a semi-colon between the two statements inside the %STR() macro function call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;trim=0 %then %let condition = 
%str(if myvars(i)&amp;lt; perct1(i) then myvars(i)=perct1(i) 
    ;if myvars(i)&amp;gt; perct2(i) then myvars(i)=perct2(i)
    )
;
%else %let condition = 
%str(myvars(i)=min(perct2(i),max(perct1(i),myvars(i))) 
    )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 20:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Help-with-if-then-statement-in-macro/m-p/616607#M18650</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-10T20:57:36Z</dc:date>
    </item>
  </channel>
</rss>

