<?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: Macro to edit code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-edit-code/m-p/811289#M319977</link>
    <description>&lt;P&gt;You can create formats from a data set using PROC FORMAT and CTNLIN.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/068-2007.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/068-2007.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the format, exactly how that data set is created will differ.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Parsing code will likely take more time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235176"&gt;@pink_poodle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As you can see below, I am re-writing a format into a bunch of conditional statements. This is for binning a variable. Who can write a quick macro to convert the format statements below into the conditional ones above? Any suggestions are appreciated.&lt;/P&gt;
&lt;P&gt;if 0 &amp;lt;= ost &amp;lt;= 5 then ost_5 = 1;&lt;BR /&gt;else if 6 &amp;lt;= ost &amp;lt;= 10 then ost_5 = 2;&lt;BR /&gt;else if 11 &amp;lt;= ost &amp;lt;= 15 then ost_5 = 3;&lt;BR /&gt;else if 16 &amp;lt;= ost &amp;lt;= 20 then ost_5 = 4;&lt;BR /&gt;else if 21 &amp;lt;= ost &amp;lt;= 25 then ost_5 = 5;&lt;BR /&gt;26 - 30 = 6&lt;BR /&gt;31 - 35 = 7&lt;BR /&gt;36 - 40 = 8&lt;BR /&gt;41 - 45 = 9&lt;BR /&gt;46 - 50 = 10&lt;BR /&gt;;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 May 2022 17:33:25 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-05-03T17:33:25Z</dc:date>
    <item>
      <title>Macro to edit code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-edit-code/m-p/811274#M319972</link>
      <description>&lt;P&gt;As you can see below, I am re-writing a format into a bunch of conditional statements. This is for binning a variable. Who can write a quick macro to convert the format statements below into the conditional ones above? Any suggestions are appreciated.&lt;/P&gt;
&lt;P&gt;if 0 &amp;lt;= ost &amp;lt;= 5 then ost_5 = 1;&lt;BR /&gt;else if 6 &amp;lt;= ost &amp;lt;= 10 then ost_5 = 2;&lt;BR /&gt;else if 11 &amp;lt;= ost &amp;lt;= 15 then ost_5 = 3;&lt;BR /&gt;else if 16 &amp;lt;= ost &amp;lt;= 20 then ost_5 = 4;&lt;BR /&gt;else if 21 &amp;lt;= ost &amp;lt;= 25 then ost_5 = 5;&lt;BR /&gt;26 - 30 = 6&lt;BR /&gt;31 - 35 = 7&lt;BR /&gt;36 - 40 = 8&lt;BR /&gt;41 - 45 = 9&lt;BR /&gt;46 - 50 = 10&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 16:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-edit-code/m-p/811274#M319972</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2022-05-03T16:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to edit code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-edit-code/m-p/811279#M319974</link>
      <description>&lt;P&gt;I would imagine that the answer depends on how you are doing the binning and what you will do with the data after it is binned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, the bin width is 5, so you can simply use that to create the new bin values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have; 
    if ost=0 then bin=1;
    else bin=floor((ost-1)/5)+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So no macros needed here. And unlikely in general you will need a macro. But, please do tell us what the next steps are.&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 16:58:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-edit-code/m-p/811279#M319974</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-03T16:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to edit code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-edit-code/m-p/811289#M319977</link>
      <description>&lt;P&gt;You can create formats from a data set using PROC FORMAT and CTNLIN.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/068-2007.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/068-2007.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the format, exactly how that data set is created will differ.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Parsing code will likely take more time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235176"&gt;@pink_poodle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As you can see below, I am re-writing a format into a bunch of conditional statements. This is for binning a variable. Who can write a quick macro to convert the format statements below into the conditional ones above? Any suggestions are appreciated.&lt;/P&gt;
&lt;P&gt;if 0 &amp;lt;= ost &amp;lt;= 5 then ost_5 = 1;&lt;BR /&gt;else if 6 &amp;lt;= ost &amp;lt;= 10 then ost_5 = 2;&lt;BR /&gt;else if 11 &amp;lt;= ost &amp;lt;= 15 then ost_5 = 3;&lt;BR /&gt;else if 16 &amp;lt;= ost &amp;lt;= 20 then ost_5 = 4;&lt;BR /&gt;else if 21 &amp;lt;= ost &amp;lt;= 25 then ost_5 = 5;&lt;BR /&gt;26 - 30 = 6&lt;BR /&gt;31 - 35 = 7&lt;BR /&gt;36 - 40 = 8&lt;BR /&gt;41 - 45 = 9&lt;BR /&gt;46 - 50 = 10&lt;BR /&gt;;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 17:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-edit-code/m-p/811289#M319977</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-03T17:33:25Z</dc:date>
    </item>
  </channel>
</rss>

