<?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 function within a data step? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194119#M36515</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your better off looking at arrays:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array crf{*} _character_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(crf);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if crf{i}="" then crf{i}="Missing";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 May 2015 15:11:53 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-05-27T15:11:53Z</dc:date>
    <item>
      <title>Macro function within a data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194118#M36514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have to do the exact same thing over and over again for multiple dataset, so I figured a macro might be helpful. This is the code I am trying to run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;%macro lab (fich, num);&lt;/P&gt;
&lt;P&gt;data &amp;amp;fich;&lt;/P&gt;
&lt;P&gt;set &amp;amp;fich;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;if CRF&amp;amp;num=" " then CRF&amp;amp;num="MISSING";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;%let &amp;amp;num=%eval(&amp;amp;num+1);&lt;/P&gt;
&lt;P&gt;if CRF&amp;amp;num=" " then CRF&amp;amp;num="MISSING";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%mend lab;&lt;/P&gt;
&lt;P&gt;%lab(temp,55);&lt;/P&gt;
&lt;P&gt;%lab(temp1,60);&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So basically, I have variables (CRF55, CRF56, CRF57..and so on) that I want it to insert the word "MISSING" when the character value is blank.&amp;nbsp; And then the same thing again for another dataset starting with var CRF60 (so this case will be CRF60, CRF61, CRF62 and so on). I have to do this for 4 varaibles per dataset and all in numerical order (e.g 55,56,57,58 and then another dataset for 60,61,62,63...etc.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone suggests an easy way to do this without manually coding every dataset?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only other solution I can think of is create multiple datasteps and do the %let statement to change the num inbetween each datasets. but I feel there is a more efficient way to code this.&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;%macro lab (fich, num);&lt;/P&gt;
&lt;P&gt;data &amp;amp;fich;&lt;/P&gt;
&lt;P&gt;set &amp;amp;fich;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;if CRF&amp;amp;num=" " then CRF&amp;amp;num="MISSING";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;%let &amp;amp;num=%eval(&amp;amp;num+1);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;data &amp;amp;fich;&lt;/P&gt;
&lt;P&gt;set &amp;amp;fich;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;if CRF&amp;amp;num=" " then CRF&amp;amp;num="MISSING";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%mend lab;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 15:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194118#M36514</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2015-05-27T15:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro function within a data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194119#M36515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your better off looking at arrays:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array crf{*} _character_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(crf);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if crf{i}="" then crf{i}="Missing";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 15:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194119#M36515</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-27T15:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro function within a data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194120#M36516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To add to RW9 you can also list specific variables instead of all character variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array crf{*} crf55 crf56 crf57;&lt;/P&gt;&lt;P&gt;or a variable list&lt;/P&gt;&lt;P&gt;array crf{*} crf55 - crf59;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 15:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194120#M36516</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-05-27T15:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro function within a data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194121#M36517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just use a format instead of modifying the data?&lt;/P&gt;&lt;P&gt;proc format ; value $miss ' '='Missing'; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 15:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-within-a-data-step/m-p/194121#M36517</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-05-27T15:58:35Z</dc:date>
    </item>
  </channel>
</rss>

