<?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: Conditional statement using SAS Macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703486#M26026</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you KurtBremser! &lt;BR /&gt;But, How do I incorporate your code with the if/then statement ?&lt;BR /&gt;Thank you!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No need for if/then. The code solves this with the formula. Try it (Maxim 4).&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2020 19:25:50 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-12-03T19:25:50Z</dc:date>
    <item>
      <title>Conditional statement using SAS Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703467#M26016</link>
      <description>&lt;P&gt;How do I change this conditional statement in to Macro? ( when event_name 1 then pmdWk=24, when event_name 2= then pmdWk=24+24=48, ..........)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Smerge;&lt;BR /&gt;merge test &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fmerge;&lt;BR /&gt;by Id ;&lt;BR /&gt;length pmdWk 8.;&lt;/P&gt;
&lt;P&gt;pmdWk = scan( PmdVisit, 2, '_');&lt;BR /&gt;length event_name 8.;&lt;/P&gt;
&lt;P&gt;event_name=scan(RD_event_name, 2,'_'); &lt;BR /&gt;if event_name= '1' then Npmdwk= pmdWk;&lt;BR /&gt;if event_name= '2' then Npmdwk= sum(pmdWk+24);&lt;BR /&gt;if event_name= '3' then Npmdwk= sum(pmdWk+48);&lt;BR /&gt;if event_name= '4' then Npmdwk= sum(pmdWk+72); and continues...........&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 18:42:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703467#M26016</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-03T18:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement using SAS Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703470#M26018</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Npmdwk= sum(pmdWk,(input(event_name,best.) - 1) * 24);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since this is a data issue, no macro is needed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 18:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703470#M26018</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-03T18:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement using SAS Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703473#M26020</link>
      <description>&lt;P&gt;Change what?&lt;/P&gt;
&lt;P&gt;How?&lt;/P&gt;
&lt;P&gt;What are you trying to do?&lt;/P&gt;
&lt;P&gt;Where does macro code come in? Macros write code. So you would start with a complete working data step first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you show no macro code so haven't got a starting place. Note that the type of DATA manipulation is typically not the place for macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might guess if the goal is to add multiples of 24 to a variable:&lt;/P&gt;
&lt;PRE&gt;data Smerge;
   merge test
         fmerge;
   by Id ;
   length pmdWk 8.;

   pmdWk = scan( PmdVisit, 2, '_');
   length event_name 8.;

   event_num=input(scan(RD_event_name, 2,'_'),best.); 
   Npmdwk= sum(pmdWk, (event_num-1)*24 );
run;&lt;/PRE&gt;
&lt;P&gt;Sometimes algebra is your friend.&lt;/P&gt;
&lt;P&gt;This might have popped out easier if you think of&lt;/P&gt;
&lt;PRE&gt;if event_name= '1' then Npmdwk= pmdWk;&lt;/PRE&gt;
&lt;P&gt;as&lt;/P&gt;
&lt;PRE&gt;if event_name= '1' then Npmdwk= sum( pmdWk, 0);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 18:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703473#M26020</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-03T18:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement using SAS Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703478#M26022</link>
      <description>Thank you KurtBremser! &lt;BR /&gt;But, How do I incorporate your code with the if/then statement ?&lt;BR /&gt;Thank you!</description>
      <pubDate>Thu, 03 Dec 2020 19:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703478#M26022</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-12-03T19:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement using SAS Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703480#M26023</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you KurtBremser! &lt;BR /&gt;But, How do I incorporate your code with the if/then statement ?&lt;BR /&gt;Thank you!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code provided does exactly what you want ... try it.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 19:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703480#M26023</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-03T19:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement using SAS Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703486#M26026</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you KurtBremser! &lt;BR /&gt;But, How do I incorporate your code with the if/then statement ?&lt;BR /&gt;Thank you!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No need for if/then. The code solves this with the formula. Try it (Maxim 4).&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 19:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Conditional-statement-using-SAS-Macro/m-p/703486#M26026</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-03T19:25:50Z</dc:date>
    </item>
  </channel>
</rss>

